Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions unicode.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,21 @@ Assign the result to a variable named swappedString.
*/

//Starter Code
// Task 1
let inputString1 = "Code";
let firstCodePoint; // Your code here
let thirdCodePoint; // Your code here
// Task 1const string1 = "Code";
const firstCodePoint = string1.charCodeAt(0); // 'C'
const thirdCodePoint = string1.charCodeAt(2); // 'd'

console.log(firstCodePoint); // 67
console.log(thirdCodePoint); // 100

// Task 2
let wordFromCodePoints; // Your code here
// Your code here

// Task 3
let inputString2 = "Launch";
let swappedString; // Your code here
Your code hereconst codePoints = [72, 101, 108, 108];
const wordFromCodePoints = String.fromCharCode(...codePoints);

console.log(wordFromCodePoints); // "Hell"

// Log all results
console.log({
Expand All @@ -103,3 +107,10 @@ console.log({
wordFromCodePoints,
swappedString,
});
const originalString = "Launch";
const firstCharCode = originalString.charCodeAt(0); // 'L'
const lastCharCode = originalString.charCodeAt(originalString.length - 1); // 'h'

const swappedString = String.fromCharCode(lastCharCode) + originalString.slice(1, -1) + String.fromCharCode(firstCharCode);

console.log(swappedString); // "hauncL"