Hi I'm new to javascript and I'm sorry if my question is silly for you.
This question was solved with the following code:
let arr = [12, 6, 53]
let a
do {
a = prompt("Enter a number")
a = Number.parseInt(a)
arr.push(a)
}
while (a != 0)
console.log(arr)
But, if I want that run the code if a == 0
rather than a != 0
i simply changed
while (a != 0)
into
while (a == 0)
But, it simply adds the number into the array
Can anyone please explain why this is happening?
I was expecting that the output should keep asking me to enter a number until a is equal to 0. I'm a bit silly (Please explain me if I'm right or wrong) I think that running the code until a != 0 and a == 0 should give the same answer in this code