Check first character of string in array and compare to another array

a = ['ghis', 'rs', 'ea','eat' ,'nentence']

let word = ''
function check(arr){
  let color = ['green']
  for(let i = 0; i < arr.length;i++){
    word += arr[i][0]
  }
 
  for(let j = 0;j < color.length;j++){
    if(word == color[j]){
     return true
    }
  }
  return false
}
console.log(check(a))

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
how to get first letter from array of string in typescript how to get first letter from array of string in javascript ES6 console.log character 'j' from array getting first character of string from array how to get the first character of a array in js how to get the fist characters of an array in javascript js get first letter of array first character of each string javascript from array use .map to get first character in a string js just let letters in array javascript find element in array of string starting with letter how to get each current letter array java script get first character of array js how to take first letter from array js get first char of an element of array get the first character of a string in an array with a for of loop get the first character of a string in an array javascript string array first letter finding first letter of item in array, javascript how to get the first string in an array how to get the first letter of the first string i an array access the first character of a string as if it were the first element of an array. save the first element and word of an array javascript how to find the first letter of a string in an array in javascript js return first character of string in arry get first letter of array javascript how to to take the first character of each array element in javascript javascript how to get first character each element of array select first few characters from each element in array javascript get the first 2 characters of string in array how to get the first letter of the string in an array in javascript how to get the first letter of each string in array in JavaScript how to find first letter of array element in javascript javascript array select first letter of each element checking array for first lette how to map first 2 characters of string in typescript return an array with first character javascript how to get the first character of a string array in javascript get three first characters of each string array how to target one letter in an array in javascript get first letter of an array in js get first letter of string in array javascript get first character of string array javascript javascript map over the first character in a string Check first character of string in array and compare to another array
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source