Skip to content

Commit 3c99ee2

Browse files
committed
Added values to the variables provided in Practice Problem LaunchCodeEducation#2 for tasks 1, 2, and 3. Added code for Practice Problem LaunchCodeEducation#1: Exercises 1, 2, and 3 underneathe the tasks from Practice Problem LaunchCodeEducation#2. Comments have been added alongside code to describe what is happening.
1 parent 683f762 commit 3c99ee2

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

unicode.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ Assign the result to a variable named swappedString.
8686
//Starter Code
8787
// Task 1
8888
let inputString1 = "Code";
89-
let firstCodePoint; // Your code here
90-
let thirdCodePoint; // Your code here
89+
let firstCodePoint = inputString1.charCodeAt(0); // 67
90+
let thirdCodePoint = inputString1.charCodeAt(2); // 100
9191

9292
// Task 2
93-
let wordFromCodePoints; // Your code here
93+
let wordFromCodePoints = String.fromCharCode(72) + String.fromCharCode(101) + String.fromCharCode(108) + String.fromCharCode(108); // "Hell"
9494

9595
// Task 3
9696
let inputString2 = "Launch";
97-
let swappedString; // Your code here
97+
let swappedString = String.fromCharCode(inputString2.charCodeAt(5)) + inputString2.slice(1,5) + String.fromCharCode(inputString2.charCodeAt(0)); // "hauncL"
9898

9999
// Log all results
100100
console.log({
@@ -103,3 +103,19 @@ console.log({
103103
wordFromCodePoints,
104104
swappedString,
105105
});
106+
107+
//Practice Problem #1: Exercise #1
108+
let myCat = "Zelda";
109+
let sumCodePoints = myCat.charCodeAt(1) + myCat.charCodeAt(2) + myCat.charCodeAt(3); // "e" = 101, "l" = 108, "d" = 100
110+
console.log(sumCodePoints); // 101 + 108 + 100 = 309
111+
112+
//Practice Problem #1: Exercise #2
113+
let firstLetter = String.fromCharCode(70); // 70 = "F"
114+
let secondLetter = String.fromCharCode(78); // 78 = "N"
115+
let combinedString = firstLetter + secondLetter;
116+
console.log(combinedString); // FN
117+
118+
//Practice Problem #1: Exercise #3
119+
let myOtherCat = "Mouse";
120+
let codePointDifference = Math.abs(myOtherCat.charCodeAt(0) - myOtherCat.charCodeAt(3)); // "M" = 77 and "s" = 115
121+
console.log(codePointDifference);

0 commit comments

Comments
 (0)