JavaScript exercises Part 2
Exercise
The program asks for words while the accept button is not pressed
// Create a new variable to save the result var result = "" // Do while loop to ask the words do { // Ask for the next word var word = prompt("Write a word"); // If the word is empty if (resultado == "") { // concatenate the words without hyphens resultado = resultado + cadena; } // If not else { // concatenate the words with hyphens result = result + "-" + word; } // While Accept button is pressed } while (confirm("Continue?")); // It cancel button is pressed show the result document.write(result);