javascriptphonetics

Python to js word to phonetics script


is there a way to do this in javascript?

if('a' in array[index] or 'A' in array[index] ):
    print(bArray[0], end = ' ')

(search array for a string, return index for that string, and then console.log(bArray[location];)


Solution

  • Yes

    // Convert the string to lower case so that it will match both 'a' and "A"
    const aIndex = array[index].toLowerCase().indexOf('a');
    if(aIndex !== -1) {
        console.log(aIndex);
    }