0
Pls i need a correction to this code. I will love a solution that uses if else statement and for loop.
I want to write a program that will ask user to enter a number, and output the square of the number. This is my code function askNumber (){ var user=prompt ("Please Enter a Num ber") if (user ="") return (null) }else if (user=Number) { return Number*Number } } askNumber()
2 Réponses
+ 4
Hi! Before I answer your question, I advice you to not paste your code inside of the post, instead, write a code, and share the link here. It makes it easier to debug and edit!
Now, to the answer.
When you're writing code, don't use things which don't help for your desired outcome. A loop won't help with anything here :) Write smart code, not pointless. Below, I linked the most efficient solution to your problem.
https://code.sololearn.com/Waz6RrorMEb4/?ref=app
+ 1
Thanks, point taken