From 7d619c2d1e5460847e922fc6ed0dc5d41d649eea Mon Sep 17 00:00:00 2001 From: alinjo Date: Mon, 23 Sep 2024 18:08:52 +0200 Subject: [PATCH] core, extension and advnaced finished --- .husky/pre-commit | 4 ---- src/advanced/strings-adv.js | 14 +++++++------- src/extensions/more-data-types.js | 14 +++++++------- src/numbers.js | 19 +++++++++++++------ src/strings.js | 8 ++++---- 5 files changed, 31 insertions(+), 28 deletions(-) delete mode 100644 .husky/pre-commit diff --git a/.husky/pre-commit b/.husky/pre-commit deleted file mode 100644 index 6b54e0b..0000000 --- a/.husky/pre-commit +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" - -npx eslint src diff --git a/src/advanced/strings-adv.js b/src/advanced/strings-adv.js index 1b1eb60..d52bac9 100644 --- a/src/advanced/strings-adv.js +++ b/src/advanced/strings-adv.js @@ -3,25 +3,25 @@ const cityStr = 'City' const shoppingList = 'apples, bananas, oranges, grapes' // TODO get the INDEX of the character where 'York' word is found in the city variable -const cityIndex = 0 +const cityIndex = city.indexOf("York") // TODO - get the substring "York" from the city variable -const citySubstring = '' +const citySubstring = city.substring(4, 8) // TODO = replace 'York' with 'Delhi' -const cityReplaced = '' +const cityReplaced = city.replace("York", "Delhi") // TODO - check if city starts with 'New' and ends with 'York' -const cityStartsWith = false -const cityEndsWith = false +const cityStartsWith = city.startsWith("New") +const cityEndsWith = city.endsWith("York") // TODO - split the shopping list into an array of items without spaces // hint (you might want to replace first, then split) -const shoppingListArray = [] +const shoppingListArray = shoppingList.split(", ") // TODO - concatenate two strings using the `${var}` syntax // make cityStrConcat equal to 'New York City' -const cityStrConcat = '' +const cityStrConcat = `${city} ${cityStr}` module.exports = { cityIndex, diff --git a/src/extensions/more-data-types.js b/src/extensions/more-data-types.js index 64cde7b..093a58b 100644 --- a/src/extensions/more-data-types.js +++ b/src/extensions/more-data-types.js @@ -1,22 +1,22 @@ // TODO: Replace the empty string in the lines below using Javascript with the correct data types // 1. Set this variable to be null -const nullVariable = '' +const nullVariable = null // 2. Set this variable to be true -const trueVariable = '' +const trueVariable = true // 2. Set this variable to be the opposite of the trueVariable (ie. false); -const falseVariable = '' +const falseVariable = false // 3. Set this variable to be undefined -const undefinedVariable = '' +const undefinedVariable = undefined // 4. get the typeof each of the above variables // hint you can use typeof variable to return a string of the variable type -const typeOfTrueVariable = '' -const typeOfFalseVariable = '' -const typeOfUndefinedVariable = '' +const typeOfTrueVariable = typeof trueVariable +const typeOfFalseVariable = typeof falseVariable +const typeOfUndefinedVariable = typeof undefinedVariable // do not edit the exported object. module.exports = { diff --git a/src/numbers.js b/src/numbers.js index ee37fa1..2e6e928 100644 --- a/src/numbers.js +++ b/src/numbers.js @@ -12,22 +12,29 @@ const numThree = 32 // NOT myAnswer = 336 // 1. Set this variable to numOne added to numTwo -const numOnePlusNumTwo = NaN +const numOnePlusNumTwo = numOne + numTwo // 2. Set this variable to numThree multiplied by numTwo -const numThreeTimesNumTwo = NaN +const numThreeTimesNumTwo = numThree * numTwo // 3. Set this variable to numThree divided by numOne -const numThreeDividedByNumOne = NaN +const numThreeDividedByNumOne = numThree / numOne // 4. Set this variable to numThree minus numOne -const numThreeMinusNumOne = NaN +const numThreeMinusNumOne = numThree - numOne // 5. Set this variable to the sum of numOne, numTwo and numThree -const sum = NaN +const sum = numOne + numTwo + numThree // 6. Set this variable to the sum of (numOne, numTwo, numThree) divided by numOne -const numBytes = NaN +const numBytes = (numOne + numTwo + numThree) / numOne + +console.log(numOnePlusNumTwo) +console.log(numThreeTimesNumTwo) +console.log(numThreeDividedByNumOne) +console.log(numThreeMinusNumOne) +console.log(sum) +console.log(numBytes) // do not edit the exported object. module.exports = { diff --git a/src/strings.js b/src/strings.js index a846086..e7a5cf5 100644 --- a/src/strings.js +++ b/src/strings.js @@ -13,16 +13,16 @@ const secondName = 'Smith' // NOT twoJanes = "JaneJane" // 1. Set this variable to firstName and secondName concatenated -const fullName = null +const fullName = firstName + " " + secondName // 2. Set this variable to the 10th character of the alphabet variable -const tenthCharacterOfAlphabet = null +const tenthCharacterOfAlphabet = alphabet.charAt(9) // 3. Set this variable by calling a method on the alphabet variable to transform it to lower case -const lowerCaseAlphabet = null +const lowerCaseAlphabet = alphabet.toLowerCase() // 4. Set this variable by using a property on the alphabet variable to get it's length -const numberOfLettersInAlphabet = null +const numberOfLettersInAlphabet = alphabet.length // do not edit the exported object. module.exports = {