From 2c204d1e2a80c0659f500aece6b9cb4a412fdde5 Mon Sep 17 00:00:00 2001 From: juliampohl Date: Sun, 30 Mar 2025 14:26:39 -0500 Subject: [PATCH] updated --- common-string-methods.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/common-string-methods.js b/common-string-methods.js index f6e2c29..4aabe05 100644 --- a/common-string-methods.js +++ b/common-string-methods.js @@ -69,23 +69,26 @@ Complete the following tasks and assign the results to the specified variables. let inputString = " Welcome to the Coding Bootcamp! Learn JavaScript today. "; // 1. Searching -let hasJavaScript; // Your code here -let codingPosition; // Your code here -let startsWithWelcome; // Your code here -let endsWithToday; // Your code here +let hasJavaScript = inputString.includes("JavaScript"); +let codingPosition = inputString.indexOf("Coding"); +let startsWithWelcome = inputString.trim().startsWith("Welcome"); +let endsWithToday = inputString.trim().endsWith("today."); // 2. Transforming -let lowercaseString; // Your code here -let uppercaseString; // Your code here -let trimmedString; // Your code here -let replacedString; // Your code here +let lowercaseString = inputString.toLowerCase(); +let uppercaseString = inputString.toUpperCase(); +let trimmedString = inputString.trim(); +let replacedString = inputString.replace("JavaScript", "coding"); // 3. Breaking Apart -let wordsArray; // Your code here +let wordsArray= trimmedString.split(" "); // 4. Retrieving -let firstCharacter; // Your code here -let extractedBootcamp; // Your code here +let firstCharacter = trimmedString.charAt(0); +let extractedBootcamp = inputString.slice( + inputString.indexOf("Bootcamp"), + inputString.indexOf("Bootcamp") + "Bootcamp".length +); // Log all results console.log({