DEV Community

Cover image for Edabit challenge 3 | strings very easy | Boolean to String Conversion
codeWithNithin
codeWithNithin

Posted on • Updated on

Edabit challenge 3 | strings very easy | Boolean to String Conversion

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());

Enter fullscreen mode Exit fullscreen mode

Discussion (0)