How to check if a value is truthy in JavaScript

1 Answer

0 votes
const s = 'javascript';
 
if (s) {
   console.log("truthy")
} 


const n = 847;
 
if (n) {
   console.log("truthy")
} 
 
 
 
 
 
/*
run:
 
"truthy"
"truthy"
 
*/

 



answered Feb 7, 2022 by avibootz
...