0
Alert specified strings?
i need this code to alert the strings that end with the arg "Letter" function HasFinalLetter(strList, Letter) { var arr = []; var str = strList.split(" "); arr.push(str); } HasFinalLetter("Hello World!", "!"); This should only alert "World! The letter can be multiple letters so we can make Letter "llo" And that should alert "Hello" I hope I worded this right
4 odpowiedzi
+ 1
No need to code anything, javascript has that!
"Hello, world!".endsWith("world!"); //true
+ 1
Single match method
function hasFinalLetter(str, letter) {
var re = new RegExp("[ ](\\w+?" + letter + ")|(^\\w+?" + letter + ")");
return str.match(re)[0];
}
https://code.sololearn.com/W6QIk5nJKxSg/?ref=app
0
I know
this was for a specific assignment somebody posted on brainly Schindlabua
lol
the function must be called "HasFirstLetter"
It must have 2 args. "strList" and "letter"
the function must output any words that end with the specified letter/letters
0
It could be a single letter
I don't remember