Skip to content

Toggle a boolean value in JavaScript

If your variable is of boolean type:

let stopVehicle = false;

If your variable is of string type:

let stopVehicle = 'true';
console.log(stopVehicle == 'true'? 'false':'true')
See also  Compare two linked lists - Hackerrank Challenge - Java Solution

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.