Answers for "Check first character of string in array and compare to another array"

0

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))
Posted by: Guest on August-12-2020

Code answers related to "Check first character of string in array and compare to another array"

Browse Popular Code Answers by Language