Skip to content

Commit b57e0f3

Browse files
committed
update: comments for clarity on initials variable creation in 2-initials.js
1 parent 12eb682 commit b57e0f3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Sprint-1/1-key-exercises/2-initials.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
let firstName = "Creola";
22
let middleName = "Katherine";
33
let lastName = "Johnson";
4+
// The code above declares these three variables: firstName, middleName, and lastName.
5+
// Each variable is assigned a string value representing each element in the name.
6+
// The task is to create a new variable take initials that combines the first character from each of these strings.
7+
// The initials variable should contain the first letter of each name, resulting in the string "CKJ".
48

59
// Declare a variable called initials that stores the first character of each string.
610
// This should produce the string "CKJ", but you must not write the characters C, K, or J in the code of your solution.
711

812
let initials = ``;
9-
13+
initials = firstName[0] + middleName[0] + lastName[0];
14+
console.log(initials); // Output: CKJ
15+
// The code above uses the bracket notation to access the first character of each string [0].
16+
// This is a common way to get the first character of a string in JavaScript.
1017
// https://www.google.com/search?q=get+first+character+of+string+mdn
11-

0 commit comments

Comments
 (0)