DEV Community

bomoniyi
bomoniyi

Posted on

Using the Or statement in JS

const response = "Reed";

// let username;

// if (response) {
// username = response;
// } else {
// username = "guest";
// }
// const result = 'Reed' || '';
// console.log(result);

const username = response || "guest";

console.log(username); // this will give you "Reed"

Top comments (0)