0
Hi, Can anyone help me with this coding challenge? My function should return a new string, that will have only capital letters.
I'm not getting any output. Please find the link of the code. https://code.sololearn.com/WxKR81RPkXQp
2 Réponses
+ 2
using "String.prototype.includes":
function onlyCapitalLetters (str) {
let newStr = " ";
for ( let i=0; i<str.length; i++) {
if ("ABCDEFGHIJKLMNOPQRSTUVWXYZ".includes(str[i])) {
newStr += str[i];
}
}
return newStr;
}
console.log(onlyCapitalLetters("Amazing"));
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
+ 1
Thank you very much Mohamed ELomari