From fde90000cbcdd56c429c96e135ad308ccec62dca Mon Sep 17 00:00:00 2001 From: Ricardo Fabio Medina <164503593+FabioMedinaD@users.noreply.github.com> Date: Tue, 29 Oct 2024 11:17:26 +0100 Subject: [PATCH 1/2] Update initials.js exercise --- week-1/exercises/initials.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/week-1/exercises/initials.js b/week-1/exercises/initials.js index 50b62103..90dfacfc 100644 --- a/week-1/exercises/initials.js +++ b/week-1/exercises/initials.js @@ -1,6 +1,11 @@ let firstName = "Creola"; let middleName = "Katherine"; let lastName = "Johnson"; +let initials =""; +initials+=(firstName[0]); +initials+=(middleName[0]); +initials+=(lastName[0]); +console.log(initials); // Declare a variable called initials that stores the first character of each string in upper case to form the user's initials // Log the variable in each case From 4266de20e385b96a4e5320b95a590f99c228e218 Mon Sep 17 00:00:00 2001 From: Ricardo Fabio Medina <164503593+FabioMedinaD@users.noreply.github.com> Date: Tue, 29 Oct 2024 11:44:59 +0100 Subject: [PATCH 2/2] create a variable to store (dir y ext) --- week-1/exercises/paths.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/week-1/exercises/paths.js b/week-1/exercises/paths.js index c91cd2ab..c7af1b4e 100644 --- a/week-1/exercises/paths.js +++ b/week-1/exercises/paths.js @@ -11,8 +11,13 @@ const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file.txt"; const lastSlashIndex = filePath.lastIndexOf("/"); +const lastPeriodIndex = filePath.lastIndexOf(".") const base = filePath.slice(lastSlashIndex + 1); +const dir = filePath.slice(0,lastSlashIndex + 1); +const ext = filePath.slice(lastPeriodIndex); console.log(`The base part of ${filePath} is ${base}`); +console.log(`The dir part of ${filePath} is ${dir}`); +console.log(`The ext part of ${filePath} is ${ext}`); // Create a variable to store the dir part of the filePath variable // Create a variable to store the ext part of the variable