Convert boolean values to strings 'Yes' or 'No'.
Madalina Pastiu

Madalina Pastiu @maddiepst

Joined:
Mar 3, 2025

Convert boolean values to strings 'Yes' or 'No'.

Publish Date: Apr 22
0 0

Instructions:
Complete the method that takes a boolean value and return a "Yes" string for true, or a "No" string for false.

Thoughts:
I used a ternary operator to cheek if the parameter is true. If it is the function will return 'Yes', otherwise it will return 'No'.

Solution:

function boolToWord( bool ){
  return bool === true ? 'Yes' :'No';
}
Enter fullscreen mode Exit fullscreen mode

This is a CodeWars Challenge of 8kyu Rank (https://www.codewars.com/kata/53369039d7ab3ac506000467/train/javascript)

Comments 0 total

    Add comment