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 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