Complete the code to check if a number is positive.
if (num > 0) { console.log('Positive'); } [1] { console.log('Not positive'); }
The else block runs when the if condition is false. Here, it covers all cases where num is not greater than 0.
Complete the code to check if a number is zero.
if (num > 0) { console.log('Positive'); } else if ([1]) { console.log('Zero'); } else { console.log('Negative'); }
The condition num === 0 checks if the number is exactly zero.
Fix the error in the else-if ladder to correctly check if a number is negative.
if (num > 0) { console.log('Positive'); } else if (num === 0) { console.log('Zero'); } else if [1] { console.log('Negative'); }
The condition must be inside parentheses in an else if statement. So (num < 0) is correct.
Fill both blanks to complete the else-if ladder that checks if a number is positive, zero, or negative.
if (num [1] 0) { console.log('Positive'); } else if (num [2] 0) { console.log('Zero'); } else { console.log('Negative'); }
The first condition checks if num is greater than zero. The second checks if it is exactly zero.
Fill all three blanks to create an else-if ladder that prints if a number is positive, zero, or negative.
if (num [1] 0) { console.log('Positive'); } else if (num [2] 0) { console.log('Zero'); } else if (num [3] 0) { console.log('Negative'); }
The conditions check if num is greater than zero, equal to zero, or less than zero respectively.