-
Notifications
You must be signed in to change notification settings - Fork 319
Expand file tree
/
Copy pathunicode.js
More file actions
29 lines (23 loc) · 801 Bytes
/
unicode.js
File metadata and controls
29 lines (23 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Starter Code
// Task 1: Extract Code Points from Characters
let inputString1 = "Code";
let firstCodePoint = inputString1.charCodeAt(0); // 'C'
let thirdCodePoint = inputString1.charCodeAt(2); // 'd'
// Task 2: Create a Word from Code Points
let wordFromCodePoints = String.fromCharCode(72, 101, 108, 108); // "Hell"
// Task 3: Swap First and Last Characters
let inputString2 = "Launch";
let firstCharCode = inputString2.charCodeAt(0); // 'L'
let lastCharCode = inputString2.charCodeAt(inputString2.length - 1); // 'h'
// Create swapped string "hauncL"
let swappedString =
String.fromCharCode(lastCharCode) +
inputString2.slice(1, -1) +
String.fromCharCode(firstCharCode);
// Log all results
console.log({
firstCodePoint,
thirdCodePoint,
wordFromCodePoints,
swappedString,
});