I am trying to find the first character in an array in JavaScript.
I have a random function (not the best, but I'm going to improve it):
function random() { var Rand = Math.floor(Math.random()*myArray.length); document.getElementById('tr').innerHTML = myArray[Rand]; }
And here is a list of my arrays.
myArray = ["where", "to", "get", "under", "over", "why"];
If the user only needs arrays with W, only words with W in the first letter are displayed. (Like "where" or "why")
I do not have much experience with JavaScript before, and I have been sitting with this problem for a long time.
source share