0
Perfect Square
Im trying to make a code where it tells you if what you enter is a perfect square of not. I used charAt method but it doesnt seem to work https://code.sololearn.com/WkcfWnFp7tK5/?ref=app
6 odpowiedzi
+ 2
I see, you try to check if the sq root contains a "."
How about this?
// make sure it's a string
let s = Math.sqrt(txt).toString();
// use includes()
if (!s.includes("."))
+ 1
What are we supposed to input?
+ 1
"!" means "not", it negates the boolean:
! true is false
0
enter in a number and itll tell you of its a perfect square or not, sorry forgot to put that
0
what does that “!” by the if statement mean? ty btw
0
// Your Mom , Hope this code helps you
function morseCode() {
for (var i = 0; i < txt.length; i++) {
switch (txt.charAt(i)) {
case "a":
morse += " •-";
break;
case "b":
morse += " -•••";
break;
case "c":
morse += " -•-•";
break;
default:
morse += "";
}
}
console.log(morse);
}