+ 1
Valid Binary String challenge
I’m trying the binary challenge for beginners. It doesn’t work that well though.. could you please tell what is wrong in my code ? Thank you https://code.sololearn.com/WoRmMVeQP7Zn/?ref=app
4 Respostas
+ 3
I don't know JavaScript buddy 😄, but I've submitted my assignment. You can take benefit from it. Hope it helpful. 😄
https://code.sololearn.com/cSdv761LCgm1/?ref=app
+ 2
- prompt already returns a string, so no need to use toString()
- your test is always true, anything is always not "0" or not "1", use && instead of ||
- you should print outside of the loop once you have determined if the whole input is binary or not, and not once per loop
Here is my shot at it:
https://code.sololearn.com/WBtEXv8jAZEs/#js
+ 1
First thing : Your test is always thrue with binary number because a binary digit is always 0 || 1. A binary digit is either 1 thus !=0 or 0 thus !=1.
You must test &&.
(If I have understood your intention...)
Next, you should either print Your result out of the loop for no repetition or better out of the function.
My solution :
https://code.sololearn.com/WX3SUtwaS586/?ref=app
+ 1
https://code.sololearn.com/cgNsaOhLAfQh/?ref=app