Daily Challenge: True or False
Goal: write a function that returns true only if all parameters are truthy.
Function
function allTruthy(...values) {
// If any value is falsy (false, 0, "", null, undefined, NaN) → return false
for (const v of values) {
if (!v) {
return false;
}
}
// If we get here, everything was truthy
return true;
}
Quick tests
{}
Try your own
Type comma-separated values. I will try to convert common literals (true/false/null/undefined/numbers/"").
{}