0

I am trying to write a javascript algorithm that checks to see if an array of characters could make a given string.

I decided to go about this by writing a function that converts the array to a string so that I can call the .match() method on that string to search for the characters of the given string.

function arrStr(arr,str) {
cleanArray(arr).match(str) ? true : false

}

function cleanArray(arr){
    return arr.join('')
}

When I attempt to execute this algorithm, I keep getting "undefined". Anybody have any ideas as to why? Thank you

1 Answers1

1

You are not returning anything from arrStr()

function arrStr(arr,str) {
   return cleanArray(arr).match(str) ? true : false

}

function cleanArray(arr){
    return arr.join('')
}
pbuzz007
  • 747
  • 1
  • 5
  • 15