Reputation: 3
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?
Upvotes: 0
Views: 1909
Reputation: 147
The comparison operator is wrong. It should be reference >= 0 not reference => 0.
Upvotes: 0
Reputation: 1107
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
Upvotes: 2