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 136 views
1 answer 153 views
2 answers 166 views
2 answers 151 views
151 views asked May 9, 2022 by avibootz
2 answers 147 views
2 answers 135 views
...