Create a function that takes a boolean variable flag and returns it as a string.
Examples
boolToString(true) ➞ "true"
boolToString(false) ➞ "false"
function tipOne(val) {
return val + '';
}
function tipTwo(val) {
return val.toString();
}
function tipThree(val) {
return String(val);
}
//you can also write using arrow functions
console.log(tipOne());
console.log(tipTwo());
console.log(tipThree());
Top comments (0)