Create a function named validateHours(). The function has a single parameter named reference. The function should examine the value of parameter named reference.This function should return Valid if reference is between 0 and 24 inclusive, otherwise it should return Invalid. Return to the sheet and enter your new formula into cell B2. Copy the formula and paste into B3:B6. Each of the cells in column B should now show the values Valid or Invalid.
function validateHours(reference) {
let result;
if (reference => 0 && reference <= 24) {
result = "Valid";
} else {
result = "Invalid";
}
return result;
}
Can someone tell me what's wrong with my code?
You comparison is wrong for the first part of your OR
function validateHours(reference) {
let result;
if (reference >= 0 && reference <= 24) {
result = "Valid";
} else {
result = "Invalid";
}
return result;
}
The above shows greater than or equal to zero
The comparison operator is wrong. It should be reference >= 0 not reference => 0.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.