I'm confused about why array.join("")
is not working properly in this function.
If the letter is a-m it will show 0 and the otherwise is 1
convertBinary("house")
➞ "01110"
function convertBinary(str) {
var jack=str.split("")
return jack.map(function(e) {
var array=[]
if(e.match(/[abcdefghijklm]/g)) {
array.push(0)
} else {
array.push(1)
}
return array.join("");
})
}
Where did I go wrong.