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
  • 1
    You have no return statement in arrStr Commented Aug 30, 2021 at 18:52

1 Answer 1

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('')
}
Sign up to request clarification or add additional context in comments.

Comments