Algorithm | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Algorithm

https://code.sololearn.com/cWPM2El9J6u7/?ref=app This is my code. I’m trying to make it so that it checks if the number entered is a perfect square. If it is, it gives the square root but if not it say that it’s not a perfect square. Is there a simple way of doing this?

29th Nov 2018, 12:00 PM
John Lebo
John Lebo - avatar
6 Answers
29th Nov 2018, 12:44 PM
Dlite
Dlite - avatar
+ 4
John Lebo actually you mean JavaScript and you entered JavaScript functions, but you executed in Java just go to web and start coding in JavaScript section Note1 : java and JavaScript are different programming languages. Note2 : you did not mentioned + operator after x in if condition 3th line. here's the example: https://code.sololearn.com/WxRe53VrvB51/?ref=app
29th Nov 2018, 12:12 PM
UwU Discover Me
2nd Dec 2018, 6:09 AM
UwU Discover Me
0
D’lite not what I meant but thanks
30th Nov 2018, 1:48 AM
John Lebo
John Lebo - avatar
0
https://code.sololearn.com/W0S6GFCUeAn1/?ref=app here’s the code in javascript
30th Nov 2018, 2:00 AM
John Lebo
John Lebo - avatar
0
what i want is for a prompt to pull up asking to type in a number, have it calculate if its a perfect square, it gives the square root if its a perfect square, say its not a perfect square if it isnt, in alerts
30th Nov 2018, 2:02 AM
John Lebo
John Lebo - avatar