Perfect Square | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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

22nd May 2022, 5:35 PM
Junior
Junior - avatar
6 Answers
+ 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("."))
22nd May 2022, 6:42 PM
Lisa
Lisa - avatar
+ 1
What are we supposed to input?
22nd May 2022, 6:37 PM
Lisa
Lisa - avatar
+ 1
"!" means "not", it negates the boolean: ! true is false
22nd May 2022, 6:51 PM
Lisa
Lisa - avatar
0
enter in a number and itll tell you of its a perfect square or not, sorry forgot to put that
22nd May 2022, 6:38 PM
Junior
Junior - avatar
0
what does that “!” by the if statement mean? ty btw
22nd May 2022, 6:44 PM
Junior
Junior - avatar
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); }
23rd May 2022, 2:33 AM
SoloProg
SoloProg - avatar