-
-
Notifications
You must be signed in to change notification settings - Fork 337
Expand file tree
/
Copy path2-initials.js
More file actions
15 lines (11 loc) · 636 Bytes
/
2-initials.js
File metadata and controls
15 lines (11 loc) · 636 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
let firstName = "Creola";
let middleName = "Katherine";
let lastName = "Johnson";
// Declare a variable called initials that stores the first character of each string.
// This should produce the string "CKJ", but you must not write the characters C, K, or J in the code of your solution.
let initials = firstName.charAt(0)+middleName.charAt(0)+lastName.charAt(0);
// or
let initials = firstName[0] + middleName[0] + lastName[0];
// or but rarely used and not recommended because it might cause bugs
let initials = firstName[0].concat(middleName[0], lastName[0]);
// https://www.google.com/search?q=get+first+character+of+string+mdn