From b49cfa1cf7144cb5c190993a1853e3ab95f89dee Mon Sep 17 00:00:00 2001 From: mickeyhaile2 <108958468+mickeyhaile2@users.noreply.github.com> Date: Thu, 24 Nov 2022 00:55:17 +0000 Subject: [PATCH 1/2] update --- .DS_Store | Bin 0 -> 6148 bytes .vscode/settings.json | 4 ++++ exercises/.DS_Store | Bin 0 -> 10244 bytes exercises/B-hello-world/README.md | 4 ++-- exercises/B-hello-world/exercise.js | 3 +++ exercises/C-variables/exercise.js | 4 +++- exercises/D-strings/exercise.js | 6 +++++- exercises/E-strings-concatenation/exercise.js | 6 +++++- exercises/F-strings-methods/exercise.js | 6 +++++- exercises/F-strings-methods/exercise2.js | 6 +++++- exercises/G-numbers/exercise.js | 5 +++++ exercises/I-floats/exercise.js | 13 +++++++++++-- exercises/J-functions/exercise.js | 4 ++-- exercises/J-functions/exercise2.js | 2 +- exercises/K-functions-parameters/exercise.js | 4 ++-- exercises/K-functions-parameters/exercise2.js | 5 ++++- exercises/K-functions-parameters/exercise3.js | 4 +++- exercises/K-functions-parameters/exercise4.js | 7 +++++-- exercises/K-functions-parameters/exercise5.js | 3 +++ exercises/L-functions-nested/exercise.js | 10 ++++++++++ mandatory/1-syntax-errors.js | 11 ++++++----- mandatory/2-logic-error.js | 8 ++++---- mandatory/3-function-output.js | 4 ++-- mandatory/4-tax.js | 9 +++++++-- 24 files changed, 97 insertions(+), 31 deletions(-) create mode 100644 .DS_Store create mode 100644 .vscode/settings.json create mode 100644 exercises/.DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..621b9b6b72594655a847dfebae371ce62a63d4d6 GIT binary patch literal 6148 zcmeHL%Sr<=6g{yOTSd`@(3Q*=hzc&1QR}h`=?~Z!Rj^LcD!Lo+2L#cD-y?_{zd=91 zjo`wa=O(dD?6gY}$%W+1+}xXcdWK0R1)#RinybJ(fC8Ifewtl|$+)y3o3Ne|QOO)f z?bT`{>2!x8gCi&q6!?n@$h(`zGTJyq&wGC-Hs0N_PEsz{kCHllh1Z?t`rPfqmOtJc zJKjBT)`r|QQ!({j7Y8^)-K&nm(r|>!;Xb!+EL4lw^P@u1XtPc^JU~DlpsFx0Q z`UpVG)2)rydha4e;vmKrQ-k!-lu0F;RArAC%B0gD*|^wZYS5%Z>B^kPR#x_eqI7lo zBOMME8w`C=ASmD~kTbXQvj6kzcGUUbPYQQIfuO*@Qb6U))$%rflHFT}ew^&J5!*hS qn8c+9bqYJX9qS9(isgR=Z5)f_f*4y&4bnpk9|Bs2&;+`rOdbh literal 0 HcmV?d00001 diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..fe95ac313 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "editor.formatOnPaste": true, + "editor.formatOnSave": true +} \ No newline at end of file diff --git a/exercises/.DS_Store b/exercises/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..88da69ca8fa40963b789f2976c226a08f293b703 GIT binary patch literal 10244 zcmeHMyN=U96upzIv_WAd*aE1KMMVLEl_*)14PFqBE~59}Fx?AR+UP~3@Tt}{7z=G@~MTX#Z4qP^gD|ebq!>cG4>|ji22TDym<)G1hx6$|JJmkq zBd7B)>`mr9AR4z;yKlDMe%&iV_bZ?mBb$ZV-CNWK-x2su@R{TKCEDk>?z^1p9k3`s z+q}cqG4Dc;gnKy;mwy04(EC0(zo0HSkJ0wPd_c<-_hCNL=Dqtd=AAR{be?ctkM{6A zN1<9DM~d%^hH0*~U*PIN**t%Ki+OsH3CCijhu>w|PxHg~L#&Az+Adc009VqEWuL3F z_zdn9N3i4CK8fS1JW3Mt=|}PCagiQ)^q8vsJ%R%L^!=;3|EH(ghAW%G)IRSVqYo+ z(r>;mW&P~9Pu|CImzvXFi&cHyI0G3c7gm53UG^f&Rn;Q zjkHznz$kZEeVYFl{tRdoXZ3bwQ;hWFF`1m*J#ngW{x45QQl}8Ej-3C?{b6=osa)J$ JWA(N9|8MP?a`ylL literal 0 HcmV?d00001 diff --git a/exercises/B-hello-world/README.md b/exercises/B-hello-world/README.md index 27282c4af..28543fc29 100644 --- a/exercises/B-hello-world/README.md +++ b/exercises/B-hello-world/README.md @@ -6,8 +6,8 @@ Inside of `exercise.js` there's a line of code that will print "Hello world!". ### 1. Run the program -- Open a terminal window -- Change directory to this folder (`cd exercises/B-hello-world`) - assuming you're at the project root +- Open a terminal windowcd exercises/B-hello-world +- Change directory to this folder (``) - assuming you're at the project root - Run the program using node (`node exercise.js`) ### 2. Experiment diff --git a/exercises/B-hello-world/exercise.js b/exercises/B-hello-world/exercise.js index b179ee953..9e77647fb 100644 --- a/exercises/B-hello-world/exercise.js +++ b/exercises/B-hello-world/exercise.js @@ -1 +1,4 @@ console.log("Hello world"); + +console.log('Hello World. I just started learning JavaScript!') + diff --git a/exercises/C-variables/exercise.js b/exercises/C-variables/exercise.js index a6bbb9786..ae3602c2c 100644 --- a/exercises/C-variables/exercise.js +++ b/exercises/C-variables/exercise.js @@ -1,3 +1,5 @@ // Start by creating a variable `greeting` - +var greeting = "hello world"; +console.log(greeting); +console.log(greeting); console.log(greeting); diff --git a/exercises/D-strings/exercise.js b/exercises/D-strings/exercise.js index 2cffa6a81..5e5bd3e8e 100644 --- a/exercises/D-strings/exercise.js +++ b/exercises/D-strings/exercise.js @@ -1,3 +1,7 @@ // Start by creating a variable `message` +var message = "This is a string"; +var messageType = typeof message; + +console.log(messageType); + -console.log(message); diff --git a/exercises/E-strings-concatenation/exercise.js b/exercises/E-strings-concatenation/exercise.js index 2cffa6a81..4fa620d71 100644 --- a/exercises/E-strings-concatenation/exercise.js +++ b/exercises/E-strings-concatenation/exercise.js @@ -1,3 +1,7 @@ // Start by creating a variable `message` +var message = "Hello, my name is "; +var name = "Micheal"; + +var greeting = message + name; +console.log(greeting); -console.log(message); diff --git a/exercises/F-strings-methods/exercise.js b/exercises/F-strings-methods/exercise.js index 2cffa6a81..f310eb835 100644 --- a/exercises/F-strings-methods/exercise.js +++ b/exercises/F-strings-methods/exercise.js @@ -1,3 +1,7 @@ // Start by creating a variable `message` +const name = " Daniel "; +name = "Daniel"; +var nameLowerCase = name.toLowerCase(); + +console.log(nameLowerCase); -console.log(message); diff --git a/exercises/F-strings-methods/exercise2.js b/exercises/F-strings-methods/exercise2.js index b4b46943d..29ff170b7 100644 --- a/exercises/F-strings-methods/exercise2.js +++ b/exercises/F-strings-methods/exercise2.js @@ -1,3 +1,7 @@ const name = " Daniel "; +name = "Daniel"; +var nameLowerCase = name.toLowerCase().trim(); + +console.log(nameLowerCase); + -console.log(message); diff --git a/exercises/G-numbers/exercise.js b/exercises/G-numbers/exercise.js index 49e7bc00b..10d8f52db 100644 --- a/exercises/G-numbers/exercise.js +++ b/exercises/G-numbers/exercise.js @@ -1 +1,6 @@ // Start by creating a variables `numberOfStudents` and `numberOfMentors` +numberOfStudents = 15; +numberOfMentors = 8; +total = numberOfMentors + numberOfStudents + +console.log(total); \ No newline at end of file diff --git a/exercises/I-floats/exercise.js b/exercises/I-floats/exercise.js index a5bbcd852..746461e87 100644 --- a/exercises/I-floats/exercise.js +++ b/exercises/I-floats/exercise.js @@ -1,2 +1,11 @@ -var numberOfStudents = 15; -var numberOfMentors = 8; +var preciseAge = 30.612437; +var roughAge = Math.round(preciseAge); +numberOfStudents = 15; +numberOfMentors = 8; +total = numberOfMentors + numberOfStudents +var percentageOfStudents = (numberOfStudents/total)*100 +let percentageOfMentors = (numberOfMentors/total)*100 +var roughStudents = Math.round(percentageOfStudents); +var roughMentors = Math.round(percentageOfMentors); +console.log(roughMentors); +console.log(roughStudents); diff --git a/exercises/J-functions/exercise.js b/exercises/J-functions/exercise.js index 0ae5850e5..fa775e951 100644 --- a/exercises/J-functions/exercise.js +++ b/exercises/J-functions/exercise.js @@ -1,7 +1,7 @@ function halve(number) { - // complete the function here + return Number*.5 } -var result = halve(12); +var result = halve(number); console.log(result); diff --git a/exercises/J-functions/exercise2.js b/exercises/J-functions/exercise2.js index 82ef5e780..9b1665f53 100644 --- a/exercises/J-functions/exercise2.js +++ b/exercises/J-functions/exercise2.js @@ -1,5 +1,5 @@ function triple(number) { - // complete function here + return number*3 } var result = triple(12); diff --git a/exercises/K-functions-parameters/exercise.js b/exercises/K-functions-parameters/exercise.js index 8d5db5e69..aff5311f6 100644 --- a/exercises/K-functions-parameters/exercise.js +++ b/exercises/K-functions-parameters/exercise.js @@ -1,6 +1,6 @@ // Complete the function so that it takes input parameters -function multiply() { - // Calculate the result of the function and return it +function multiply(a,b) { + return a*b } // Assign the result of calling the function the variable `result` diff --git a/exercises/K-functions-parameters/exercise2.js b/exercises/K-functions-parameters/exercise2.js index db7a8904b..a487c16e4 100644 --- a/exercises/K-functions-parameters/exercise2.js +++ b/exercises/K-functions-parameters/exercise2.js @@ -1,5 +1,8 @@ // Declare your function first - +function name(a,b) { + return a/b + +} var result = divide(3, 4); console.log(result); diff --git a/exercises/K-functions-parameters/exercise3.js b/exercises/K-functions-parameters/exercise3.js index 537e9f4ec..c45b2d9cf 100644 --- a/exercises/K-functions-parameters/exercise3.js +++ b/exercises/K-functions-parameters/exercise3.js @@ -1,5 +1,7 @@ // Write your function here - +function name(a,b) { + return +} var greeting = createGreeting("Daniel"); console.log(greeting); diff --git a/exercises/K-functions-parameters/exercise4.js b/exercises/K-functions-parameters/exercise4.js index 7ab44589e..6e58fe49c 100644 --- a/exercises/K-functions-parameters/exercise4.js +++ b/exercises/K-functions-parameters/exercise4.js @@ -1,5 +1,8 @@ // Declare your function first - +function name(a,b) { + return a+b + +} // Call the function and assign to a variable `sum` - +var sum= name(1,2) console.log(sum); diff --git a/exercises/K-functions-parameters/exercise5.js b/exercises/K-functions-parameters/exercise5.js index 7c5bcd605..cb47c6333 100644 --- a/exercises/K-functions-parameters/exercise5.js +++ b/exercises/K-functions-parameters/exercise5.js @@ -1,4 +1,7 @@ // Declare your function here +function createLongGreeting(a, b) { + return "I am " + a + " and I am " + b + " years old" +} const greeting = createLongGreeting("Daniel", 30); diff --git a/exercises/L-functions-nested/exercise.js b/exercises/L-functions-nested/exercise.js index a5d377442..d8c5aa75b 100644 --- a/exercises/L-functions-nested/exercise.js +++ b/exercises/L-functions-nested/exercise.js @@ -3,3 +3,13 @@ var mentor2 = "Irina"; var mentor3 = "Mimi"; var mentor4 = "Rob"; var mentor5 = "Yohannes"; +function getAgeInDays(age) { + return age * 365; +} + +function createCreeting(name, age) { + var ageInDays = getAgeInDays(age); + var message = + "My Name is " + name + " and I was born over " + ageInDays + " days ago!"; + return message; +} \ No newline at end of file diff --git a/mandatory/1-syntax-errors.js b/mandatory/1-syntax-errors.js index a10cc9ac2..5ba2ee789 100644 --- a/mandatory/1-syntax-errors.js +++ b/mandatory/1-syntax-errors.js @@ -1,16 +1,17 @@ // There are syntax errors in this code - can you fix it to pass the tests? -function addNumbers(a b c) { +function addNumbers(a, b, c) { return a + b + c; } -function introduceMe(name, age) - return "Hello, my name is " + name "and I am " age + "years old"; +function introduceMe(name, age){ + return "Hello, my name is "+ name + " and I am " + age + " years old"; +} function getTotal(a, b) { - total = a ++ b; + let total = a + b; - return "The total is total"; + return "The total is " + total; } /* diff --git a/mandatory/2-logic-error.js b/mandatory/2-logic-error.js index 9cca7603b..4902e77f2 100644 --- a/mandatory/2-logic-error.js +++ b/mandatory/2-logic-error.js @@ -1,16 +1,16 @@ // The syntax for this function is valid but it has an error, find it and fix it. function trimWord(word) { - return wordtrim(); + return word.trim(); } function getStringLength(word) { - return "word".length(); + return word.length; } function multiply(a, b, c) { - a * b * c; - return; + return a * b * c; + } /* diff --git a/mandatory/3-function-output.js b/mandatory/3-function-output.js index 5a953ba60..3eec4c7d4 100644 --- a/mandatory/3-function-output.js +++ b/mandatory/3-function-output.js @@ -2,12 +2,12 @@ function getRandomNumber() { return Math.random() * 10; } - +// picks a random value to times with ten // Add comments to explain what this function does. You're meant to use Google! function combine2Words(word1, word2) { return word1.concat(word2); } - +// connects two strings together function concatenate(firstWord, secondWord, thirdWord) { // Write the body of this function to concatenate three words together. // Look at the test case below to understand what this function is expected to return. diff --git a/mandatory/4-tax.js b/mandatory/4-tax.js index ba77c7ae2..81fd16f93 100644 --- a/mandatory/4-tax.js +++ b/mandatory/4-tax.js @@ -5,7 +5,12 @@ Sales tax is 20% of the price of the product. */ -function calculateSalesTax() {} + +function calculateSalesTax(priceOfProduct) { +var salesTax = (priceOfProduct*.2); + + return salesTax +} /* CURRENCY FORMATTING @@ -17,7 +22,7 @@ function calculateSalesTax() {} Remember that the prices must include the sales tax (hint: you already wrote a function for this!) */ -function addTaxAndFormatCurrency() {} +function addTaxAndFormatCurrency(priceOfProduct) {} /* =================================================== From aba6453ece46b8a5580eb0d2e9bc86508fd735a3 Mon Sep 17 00:00:00 2001 From: mickeyhaile2 <108958468+mickeyhaile2@users.noreply.github.com> Date: Thu, 24 Nov 2022 01:06:26 +0000 Subject: [PATCH 2/2] updated 2 --- exercises/L-functions-nested/exercise.js | 23 ++++++++++++++--------- mandatory/4-tax.js | 16 +++++++++------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/exercises/L-functions-nested/exercise.js b/exercises/L-functions-nested/exercise.js index d8c5aa75b..ab6f4a340 100644 --- a/exercises/L-functions-nested/exercise.js +++ b/exercises/L-functions-nested/exercise.js @@ -3,13 +3,18 @@ var mentor2 = "Irina"; var mentor3 = "Mimi"; var mentor4 = "Rob"; var mentor5 = "Yohannes"; -function getAgeInDays(age) { - return age * 365; -} -function createCreeting(name, age) { - var ageInDays = getAgeInDays(age); - var message = - "My Name is " + name + " and I was born over " + ageInDays + " days ago!"; - return message; -} \ No newline at end of file + function mentorUpperCase(a) { + return a.toUpperCase(); + } + + function shoutyGreeting(a) { + let nameUpperCase = mentorUpperCase(a); + return "HELLO".concat(" ", nameUpperCase); + } + + console.log(shoutyGreeting(mentor1)); + console.log(shoutyGreeting(mentor2)); + console.log(shoutyGreeting(mentor3)); + console.log(shoutyGreeting(mentor4)); + console.log(shoutyGreeting(mentor5)); \ No newline at end of file diff --git a/mandatory/4-tax.js b/mandatory/4-tax.js index 81fd16f93..c1884b035 100644 --- a/mandatory/4-tax.js +++ b/mandatory/4-tax.js @@ -6,12 +6,12 @@ */ -function calculateSalesTax(priceOfProduct) { -var salesTax = (priceOfProduct*.2); - - return salesTax -} +function calculateSalesTax() {} + function calculateSalesTax(sales) { + const calcTax = sales * 0.2 + sales; + return calcTax; + } /* CURRENCY FORMATTING =================== @@ -21,8 +21,10 @@ var salesTax = (priceOfProduct*.2); Remember that the prices must include the sales tax (hint: you already wrote a function for this!) */ - -function addTaxAndFormatCurrency(priceOfProduct) {} +function addTaxAndFormatCurrency() {} + function addTaxAndFormatCurrency(sales) { + return "£" + calculateSalesTax(sales).toFixed(2); +n /* ===================================================