Hi, Can anyone help me with this coding challenge? My function should return a new string, that will have only capital letters. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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

12th Mar 2020, 7:36 PM
Jojo
Jojo - avatar
2 Answers
+ 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
12th Mar 2020, 8:07 PM
MO ELomari
+ 1
Thank you very much Mohamed ELomari
12th Mar 2020, 8:08 PM
Jojo
Jojo - avatar