JS prompt - calculator (калькулятор) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

JS prompt - calculator (калькулятор)

Help me, please. How to do in the calculator if you have not entered a number, then offer to enter again until you enter a number. And that would not count either 0 or nan. Помогите мне, пожалуйста. Как в калькуляторе сделать если ввели не цифру, то предлагать еще раз ввести, пока не введет цифру. И что бы не считал или 0 или nan.

16th Nov 2020, 9:11 PM
Марина Гординская
Марина Гординская - avatar
6 Answers
+ 5
Ok, here's my solution, I'm using the do...while statement: https://code.sololearn.com/W45ToHTR466g/?ref=app
16th Nov 2020, 9:34 PM
CoffeeByte
CoffeeByte - avatar
+ 5
Марина Гординская Try do{...}while(!val)
16th Nov 2020, 9:45 PM
CoffeeByte
CoffeeByte - avatar
+ 4
I can't open the code, please insert it clicking the insert button.
16th Nov 2020, 9:19 PM
CoffeeByte
CoffeeByte - avatar
16th Nov 2020, 9:23 PM
Марина Гординская
Марина Гординская - avatar
+ 1
Thank you, this is what I need. What can you do with the cancel function? If you press it, it counts 0
16th Nov 2020, 9:42 PM
Марина Гординская
Марина Гординская - avatar
+ 1
Thanks, I'll try
16th Nov 2020, 9:49 PM
Марина Гординская
Марина Гординская - avatar