Pick the best code statement to log a warning if the speed is above 80mph?: A.)
ID: 3886557 • Letter: P
Question
Pick the best code statement to log a warning if the speed is above 80mph?:
A.)
var speed = 90;
console.log(“Warning: You are driving above 80mph”);
B.)
var speed = 90;
if (speed) {
console.log(“Warning: You are driving above 80mph”);
} else {
console.log(“You are driving within the speed limit”);
}
C.)
var speed = 90;
if (speed > 80) {
console.log(“Warning: You are driving above 80mph”);
} else {
console.log(“You are driving within the speed limit”);
}
D.)
var speed = 90;
if (speed > 80) {
console.log(“Warning: You are driving above 80mph”);
} else {
console.log(“You are driving within the speed limit”);
}
Explanation / Answer
In the question log a warning when the speed is above 80mph.
i)It has to check the speed value.so,we have to write if,else control structures.
that control structures included in b),c),d) but in b) it just checking the speed value .it doesn't check whether that value >80 or not so,
answer is c or d
but in given options c and d are same.
so,c) and d) are right snippet for given question.