Skip to main content

Ivan Teoh

Something personal yet public

164-exercise26.js

(Source)

while (true) {
    var theNumber = prompt('What the value of 2 + 2 is?', '');
    if (theNumber == '4') {
        alert('Correct! Well done.');
        break;
    }
    else if (theNumber == '3' || theNumber == '5')
        alert('Almost!');
    else
        alert('Ops! Please try again!');
}