function onlyCapitalLetters (str) { let newStr = ""; for (let i = 0; i < str.length; i ++) { if (str[i].includes("ABCDEFGHIJKLMNOPQRSTUVWXYZ")) { newStr += str[i]; } } return newStr; } onlyCapitalLetters("AMazing"); // should get AM Hi, I'm trying to write a function, that will return a new string with only capital letters. When I try to run this function, I don't see any output. Please help!!!
A-Zstr[i].includes("ABCDEFGHIJKLMNOPQRSTUVWXYZ")should be"ABCDEFGHIJKLMNOPQRSTUVWXYZ".includes(str[i])"Your String".match(/[A-Z]+/g).join("")