Skip to content

Commit b7b178b

Browse files
committed
generateBandName solutions
1 parent d31ac48 commit b7b178b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/01-2-basics.js

+18
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,24 @@
1111
function generateBandName(clothingColor, lastFoodEaten) {
1212
// Your code here
1313
// Initialize bandName to an empty string
14+
let bandName = "";
1415
// Function to capitalize the first letter of each word
16+
17+
function capitalizeFirstLetter(word) {
18+
if (typeof word === "number") {
19+
return word.toString();
20+
}
21+
if (typeof word !== "string" || word === null) {
22+
return "";
23+
}
24+
return word.charAt(0).toUpperCase() + word.slice(1).toLocaleLowerCase();
25+
}
1526
// Construct the band name
27+
bandName =
28+
"The " +
29+
capitalizeFirstLetter(clothingColor) +
30+
" " +
31+
capitalizeFirstLetter(lastFoodEaten);
32+
33+
return bandName;
1634
}

0 commit comments

Comments
 (0)