Skip to content

Commit dd7939f

Browse files
authored
Convert boolean values to strings Yes or No in JS
1 parent 43eeca8 commit dd7939f

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// 1 Plain solution
2+
function boolToWord (bool) {
3+
if (bool === true) {
4+
return "Yes";
5+
} else {
6+
return "No";
7+
}
8+
}
9+
10+
// 2 Optimized solution
11+
function boolToWord (bool) {
12+
return bool ? "Yes" : "No"
13+
}
14+
15+
// 3 Clever solution
16+
const boolToWord = b => ["No", "Yes"][+b]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Convert boolean values to strings 'Yes' or 'No'. (8 kyu)
2+
3+
https://www.codewars.com/kata/53369039d7ab3ac506000467
4+
5+
Complete the method that takes a boolean value and return a `"Yes"` string for `true`, or a `"No"` string for `false`.

README.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ JS Video Tutorial) :
660660
/ [[Java](<7kyu/(7%20kyu)%20Two%20to%20One/(7%20kyu)%20Two%20to%20One.java>)]
661661
/ [[Go](<7kyu/(7%20kyu)%20Two%20to%20One/(7%20kyu)%20Two%20to%20One.go>)]
662662

663-
## 8 kyu Katas (27)
663+
## 8 kyu Katas (28)
664664

665665
**[(8 kyu) Abbreviate a Two Word Name](https://www.codewars.com/kata/abbreviate-a-two-word-name)**
666666
([Description](<8kyu/(8%20kyu)%20Abbreviate%20a%20Two%20Word%20Name/(8%20kyu)%20Abbreviate%20a%20Two%20Word%20Name.md>) +
@@ -718,6 +718,17 @@ JS Video Tutorial) :
718718
/ [Java]
719719
/ [Go]
720720
<br>
721+
**[(8 kyu) Convert boolean values to strings 'Yes' or 'No'.](https://www.codewars.com/kata/544675c6f971f7399a000e79/)** ([Description](<8kyu/(8%20kyu)%20Convert%20boolean%values%20to%20strings%20Yes%20or%20No/(8%20kyu)%20Convert%20boolean%values%20to%20strings%20Yes%20or%20No.md>) +
722+
JS Video Tutorial) :
723+
[[JavaScript](<8kyu/(8%20kyu)%20Convert%20boolean%values%20to%20strings%20Yes%20or%20No/(8%20kyu)%20Convert%20boolean%values%20to%20strings%20Yes%20or%20No.js>)]
724+
/ [TypeScript]
725+
/ [Python]
726+
/ [Rust]
727+
/ [C++]
728+
/ [C#]
729+
/ [Java]
730+
/ [Go]
731+
<br>
721732
**[(8 kyu) Count of positives - sum of negatives](https://www.codewars.com/kata/count-of-positives-slash-sum-of-negatives)** ([Description](<8kyu/(8%20kyu)%20Count%20of%20positives%20-%20sum%20of%20negatives/(8%20kyu)%20Count%20of%20positives%20-%20sum%20of%20negatives.md>) +
722733
[JS Video Tutorial](https://www.youtube.com/watch?v=Agva6gkNmok)) :
723734
[[JavaScript](<8kyu/(8%20kyu)%20Count%20of%20positives%20-%20sum%20of%20negatives/(8%20kyu)%20Count%20of%20positives%20-%20sum%20of%20negatives.js>)]

0 commit comments

Comments
 (0)