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 145 views
1 answer 162 views
2 answers 180 views
2 answers 164 views
164 views asked May 9, 2022 by avibootz
2 answers 160 views
2 answers 146 views
...