let input;
let studentAges = Array();
console.log("Enter an age or X to finish");
do
{
input = prompt('Enter age ');
studentAges.push(input);
} while ( input !== "X")
console.log(studentAges);
This is node, and input is entered on the console.
The problem is that the array includes the 'X'. E.g. I end up with [10, 12, 14, 'X']
How can I stop before the 'X'? I could just test for the X and not push it onto the array. But I'd like to keep this simpler. I think this is something about 'pre-conditions' and 'post conditions'?
Thank you