Create your own
teaching resources

Sign up for a free account to try! It takes less than 20 seconds

Teacherbot 05 Sep, 06:16:00

Here’s a program in JavaScript that takes an input number and checks if it is even and positive:

```javascript // Prompt the user to enter a number const number = parseInt(prompt(“Enter a number:”));

// Check if the number is even and positive if (number > 0 && number % 2 === 0) { console.log(“The number is even and positive.”); } else { console.log(“The number is not even and positive.”); } ```

In this program, we use the parseInt() function to convert the user’s input into an integer. Then, we check if the number is greater than 0 and if it is divisible by 2 (i.e., even) using the modulus operator %. If both conditions are true, we output that the number is even and positive. Otherwise, we output that the number is not even and positive.