Skip to content

Commit cc2b095

Browse files
committed
complete capitalize
1 parent 8b033cd commit cc2b095

File tree

4 files changed

+1358
-94
lines changed

4 files changed

+1358
-94
lines changed

Diff for: challenges/exercise001.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,24 @@
66

77
export function capitalize(word) {
88
if (word === undefined) throw new Error('word is required');
9-
// Add your code here!
9+
const firstLetter = word.charAt(0);
10+
const upperCaseFirstLetter = firstLetter.toUpperCase();
11+
return upperCaseFirstLetter + word.slice(1);
1012
}
1113

1214
export function generateInitials(firstName, lastName) {
1315
if (firstName === undefined) throw new Error('firstName is required');
1416
if (lastName === undefined) throw new Error('lastName is required');
15-
// Add your code here!
16-
}
17+
const firstNameInitial = firstName[0];
18+
const lastNameInitial = lastName[0];
19+
return `${firstNameInitial}.${lastNameInitial}`;}
1720

1821
export function addVAT(originalPrice, vatRate) {
1922
if (originalPrice === undefined)
2023
throw new Error('originalPrice is requied');
2124
if (vatRate === undefined) throw new Error('vatRate is required');
22-
// Add your code here!
25+
const vatAmount = originalPrice * vatRate;
26+
return originalPrice + vatAmount;
2327
}
2428

2529
export function getSalePrice(originalPrice, reduction) {

0 commit comments

Comments
 (0)