How to toggle a boolean in Node.js

2 Answers

0 votes
let bool = true;
 
bool = !bool;
console.log(bool);
 
bool = !bool;
console.log(bool);
 
bool = !bool;
console.log(bool);
 
bool = !bool;
console.log(bool);
   
   
   
   
/*
run:
 
false
true
false
true
   
*/

 



answered May 9, 2022 by avibootz
0 votes
console.log(!true); 
console.log(!false); 
 
   
   
   
   
/*
run:
 
false
true
   
*/

 



answered May 9, 2022 by avibootz

Related questions

2 answers 270 views
1 answer 250 views
2 answers 297 views
2 answers 274 views
274 views asked May 9, 2022 by avibootz
2 answers 258 views
2 answers 251 views
...