Write a program by java script that asks the user for an even number. It then continues to halve the number (printing the result of halving) until it becomes an odd number. For example, if the user gives 1000, your program should output: 500, 250, 125

Respuesta :

A program by Java Script that executes the above function is given as follows:

function halveUntilOdd(n) {

 // keep halving the number until it becomes odd

 while (n % two === zero) {

   n = n / 2;

   console.log(n);

 }

}

//request an even number from the user

let n = prompt("please type an even integer:");

// make sure the number is even

if (n % two === zero) {

 halveUntilOdd(n);

} else {

 console.log("The number you entered is not even. Please try again.");

}

What is Java?

Java is a popular object-oriented computer language and software application that is utilized on billions of devices such as laptop computers, portable devices, gaming consoles, medical equipment, and many more.

The Java programming language arose from a research endeavor to provide powerful software for a wide range of network connections and embedded systems. The objective was to create a lightweight, dependable, portable, networked, real-time operating platform.

Learn more about Java:
https://brainly.com/question/25458754
#SPJ1