-
-
Notifications
You must be signed in to change notification settings - Fork 475
ZA2-B Ogundele-JS Core1-Coursework-Wk1 #336
base: master
Are you sure you want to change the base?
Changes from all commits
68f6976
1d282cf
24a5de5
304da50
a0b6878
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "editor.formatOnSave": true, | ||
| "editor.formatOnPaste": true | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,4 @@ | ||
| console.log("Hello world"); | ||
| console.log("Hello World.", "I just started learning JavaScript", "I am very new at this, Lets see if this worked"); | ||
| // console.log(I am very new at this); | ||
| console.log(5); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| // Start by creating a variable `greeting` | ||
|
|
||
| var greeting = "Hi there"; | ||
| console.log(greeting); | ||
| console.log(greeting); | ||
| console.log(greeting); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| // Start by creating a variable `message` | ||
| var message = "This is a string exercise"; | ||
| var messageType = typeof message; | ||
|
|
||
| console.log(messageType); | ||
|
|
||
| console.log(message); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| // Start by creating a variable `message` | ||
| var greetingStart = "Hello, my name is "; | ||
| var myName = "Berenice"; | ||
|
|
||
| console.log(message); | ||
| var greeting = greetingStart + myName; | ||
|
|
||
| console.log(greeting); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| // Start by creating a variable `message` | ||
|
|
||
| console.log(message); | ||
| const greetingStart = "My name is "; | ||
| const myName = "Daniel" | ||
| const namePlusLength = " and my name is 6 characters long" | ||
|
|
||
| console.log(greetingStart + myName + namePlusLength); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,18 @@ | ||
| const name = " Daniel "; | ||
| const greetingStart = "My name is "; | ||
| const myName = " Daniel " | ||
| const namePlusLength = " and my name is 6 characters long" | ||
| const message = myName.trim(); | ||
|
|
||
| console.log(message); | ||
| console.log(myName.trim()); | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| // const name = " Daniel "; | ||
| // const message = name.trim(); | ||
|
|
||
| // console.log(message); | ||
| // //was not sure if i should combine the X2 exercises | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,6 @@ | ||
| // Start by creating a variables `numberOfStudents` and `numberOfMentors` | ||
|
|
||
| let numberOfStudents = 15; | ||
| let numberOfMentors = 8; | ||
|
|
||
| console.log(numberOfStudents + numberOfMentors); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,7 @@ | ||
| var numberOfStudents = 15; | ||
| var numberOfMentors = 8; | ||
| var numberOfStudents = 15 / 23; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a tip to keep the original request before you change it. Its not wrong but just helps for troubleshooting. So for e.g. perhaps you could have had: Also need to multiply by 100 to get percentage before using Math.round. So perhaps in addition |
||
| var percentagePerGroup = Math.round(numberOfStudents); | ||
| console.log(numberOfStudents); | ||
|
|
||
| var numberOfMentors = 8 / 23; | ||
| var percentagePerGroup = Math.round(numberOfMentors) | ||
| console.log(numberOfMentors); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| // Complete the function so that it takes input parameters | ||
| function multiply() { | ||
| function multiply(num1, num2) { | ||
| // Calculate the result of the function and return it | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inside the function the calculation needs to occur and answer be returned. |
||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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; | ||
| total = a + b; | ||
|
|
||
| return "The total is total"; | ||
| return "The total is " + total; | ||
| } | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. great understanding of the fundamentals in this exercise |
||
| /* | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,15 @@ | ||
| // The syntax for this function is valid but it has an error, find it and fix it. | ||
|
|
||
| function trimWord(word) { | ||
| return wordtrim(); | ||
| return trimWord(); | ||
| } | ||
|
|
||
| function getStringLength(word) { | ||
| return "word".length(); | ||
| return word.length(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi. This one is similar to the top in exercises, where u got the trim function right. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here length is a property not a method, that is it should not have () parenthesis after the word. |
||
| } | ||
|
|
||
| function multiply(a, b, c) { | ||
| a * b * c; | ||
| return; | ||
| return a + b + c; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is syntactically correct, just instead of pluses it should have been multiplication |
||
| } | ||
|
|
||
| /* | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,13 +2,20 @@ | |
| function getRandomNumber() { | ||
| return Math.random() * 10; | ||
| } | ||
| //the function will get numbers between 1 and 10 and round it up or down | ||
|
|
||
| // Add comments to explain what this function does. You're meant to use Google! | ||
| function combine2Words(word1, word2) { | ||
| return word1.concat(word2); | ||
| } | ||
| // /two words will be combined to form a new word | ||
|
|
||
| function concatenate(firstWord, secondWord, thirdWord) { | ||
| var one = "firstWord" | ||
| var two = "secondWord" | ||
| var three = "thirdWord" | ||
|
|
||
| console.log(one + two + three); | ||
| // 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. | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this definitely will work, but the requirement asks you to use the concat function used just before. |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure either, but great use of .trim(), good method to remember