This repository was archived by the owner on Jan 14, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 475
South Africa_Class-1 - Douglas Van Der Merwe - JavaScript Core - 1 #40
Closed
Closed
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
8dc67a8
B done
AbdulqadirAbdillahi fe52111
C
AbdulqadirAbdillahi fbd526d
exercide d
AbdulqadirAbdillahi 7b792b0
e exercise
AbdulqadirAbdillahi ea1271e
answers f to k
AbdulqadirAbdillahi 1da95c7
Update exercise.js
AbdulqadirAbdillahi 11dd1d9
Update 1-syntax-errors.js
AbdulqadirAbdillahi 1ba5862
Update 2-logic-error.js
AbdulqadirAbdillahi e2962b6
Update 3-function-output.js
AbdulqadirAbdillahi 78a1327
Update 4-tax.js
AbdulqadirAbdillahi ef5eef6
Update 1-syntax-errors.js
DouglasVDM d705ed0
Add comments after google search
DouglasVDM 6abe75e
Add comments to changes
DouglasVDM c249f4d
C-variables
DouglasVDM d32cd9e
Exercise-D
DouglasVDM 536905c
E-Strings-Concatenation
DouglasVDM 88f9484
F-strings-methods
DouglasVDM 566951e
F-strings-methods-exercise2
DouglasVDM 40591b2
G-numbers
DouglasVDM 3a15ad7
I-floats-exercise
DouglasVDM 19b9c40
J-functions-exercise.js
DouglasVDM 87245d1
J-functions-exercise2
DouglasVDM 5d42014
K-functions-parameters-exercise1
DouglasVDM b9bfb6e
K-functions-parameters-exercise2
DouglasVDM 75d4e88
K-functions-parameters-exercise3
DouglasVDM e6de8c0
K-functions-parameters-exercise4
DouglasVDM 85c3407
K-functions-parameters-exercise5
DouglasVDM b895d6e
L-functions-nested-exercise1
DouglasVDM 38b2718
L-functions-nested-exercise1-add %
DouglasVDM 7340001
L-functions-nested-exercise1-add function for message
DouglasVDM cdb6a42
L-functions-nested-exercise2
DouglasVDM 84755e7
mandatory-3-function-output
DouglasVDM d0a1842
Mandatory-4-tax-meet
DouglasVDM 2b62668
L-functions-exercise-meet
DouglasVDM 0573375
1-currency-conversion
DouglasVDM b04fffd
extra-2-piping
DouglasVDM e363d53
mandatory-4-tax-cleanup
DouglasVDM 8e49331
extra-2-piping
DouglasVDM 20b1ff6
Merge branch 'master' of https://github.com/DouglasVDM/JavaScript-Cor…
DouglasVDM File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,12 @@ | ||
| console.log("Hello world"); | ||
| console.log("Hello World"); | ||
| console.log(5); | ||
|
|
||
| // When I console.log several things at once, I get a list of answers. | ||
|
|
||
| // When I get rid of quotes,I get a syntax error. | ||
| console.log(Hello World.I just started learning JavaScript!); | ||
|
|
||
| console.log("Hello World. I just started learning JavaScript!"); | ||
|
|
||
| // A number without quotes. | ||
| console.log(205); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,12 @@ | ||
| // Start by creating a variable `greeting` | ||
| var approach = "greeting";// Start by creating a variable `greeting` | ||
|
|
||
| let greeting = "Hello World" | ||
| console.log(greeting); | ||
|
|
||
| var approach = "greeting";// Start by creating a variable `greeting` | ||
|
|
||
| console.log(greeting); | ||
|
|
||
| var approach = "greeting";// Start by creating a variable `greeting` | ||
|
|
||
| console.log(greeting); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,13 @@ | ||
| // Start by creating a variable `message` | ||
| const message = "This is a String"; | ||
| const messageType = typeof message; | ||
|
|
||
|
|
||
| console.log(message); | ||
| console.log(messageType); | ||
|
|
||
| // My copy | ||
| const myText = "This is a String of Douglas"; | ||
| const usingTypeof = typeof myText; | ||
|
|
||
| console.log(myText); | ||
| console.log(usingTypeof); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,13 @@ | ||
| // Start by creating a variable `message` | ||
| // const introduction = "Hello my name is"; | ||
| // const name = " Abdulqadir"; | ||
|
|
||
| console.log(message); | ||
| // console.log(introduction); | ||
| // console.log(name); | ||
|
|
||
| // My copy | ||
| let standardIntro = "Hello, my first name is"; | ||
| let yourName = " Douglas."; | ||
|
|
||
| let greeting = standardIntro + yourName; | ||
|
|
||
| console.log(greeting); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,11 @@ | ||
| // Start by creating a variable `message` | ||
| // let name = "Abdulqadir"; | ||
| // let nameLength = name.length; | ||
|
|
||
| console.log(message); | ||
| // console.log(`My name is ${name} and my name is ${name.length} characters long`); | ||
|
|
||
|
|
||
| let myName = "Douglas Trainee"; | ||
| let myNameLength = myName.length; | ||
|
|
||
| // With interpolation, I don't need to create another variable for the greeting text. | ||
| console.log(`My name is ${myName} and my name is ${myNameLength} characters long`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,17 @@ | ||
| const name = " Daniel "; | ||
| let name = "Abdulqadir"; | ||
| let addTrim = name.trim(); | ||
| let newNameLength = addTrim.length; | ||
|
|
||
| console.log(message); | ||
| console.log(`my name is ${addTrim} and my name is ${newNameLength} characters long`); | ||
|
|
||
| let myName = " Douglas Trainee "; | ||
| let myNameLength = myName.length; | ||
|
|
||
| let myNameTrim = myName.trim(); | ||
| let myNewNameLength = myNameTrim.length; | ||
|
|
||
| // 19 characters for myName | ||
| console.log(`My name is ${myName} and my name is ${myNameLength} characters long`); | ||
|
|
||
| // The whitespaces are removed: 15 characters for myName | ||
| console.log(`My name is ${myNameTrim} and my name is ${myNewNameLength} characters long`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,17 @@ | ||
| // Start by creating a variables `numberOfStudents` and `numberOfMentors` | ||
| // let numberOfStudents = 15; | ||
| // let numberOfMentors = 3; | ||
| // let total = numberOfStudents + numberOfMentors; | ||
|
|
||
| // console.log(`number of students: ${numberOfStudents}`); | ||
| // console.log(`number of mentors: ${numberOfMentors}` ); | ||
| // console.log(`total number of students and mentors: ${total}`); | ||
|
|
||
| // My copy. | ||
| let numberOfStudents = 30; | ||
| let numberOfMentors = 10; | ||
| let total = numberOfStudents + numberOfMentors; | ||
|
|
||
| console.log(`Number of students: ${numberOfStudents}`); | ||
| console.log(`Number of mentors: ${numberOfMentors}`); | ||
| console.log(`Total number of students and mentors: ${total}`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,23 @@ | ||
| var numberOfStudents = 15; | ||
| var numberOfMentors = 8; | ||
| // var numberOfStudents = 15; | ||
| // var numberOfMentors = 8; | ||
| // var total = numberOfStudents + numberOfMentors; | ||
|
|
||
| // var convertStudent = numberOfStudents/total*100; | ||
| // var convertMentors = numberOfMentors/total*100; | ||
|
|
||
| // var percentageOfStudents = Math.round(convertStudent); | ||
| // var percentageOfMentors = Math.round(convertMentors); | ||
|
|
||
| // console.log(`Student percentage: ${percentageOfStudents}%`); | ||
| // console.log(`Student percentage: ${percentageOfMentors}%`); | ||
|
|
||
| var numberOfStudents = 30; | ||
| var numberOfMentors = 10; | ||
| var total = numberOfStudents + numberOfMentors; | ||
|
|
||
| var convertStudents = numberOfStudents / total * 100; | ||
| var convertMentors = numberOfMentors / total * 100; | ||
|
|
||
| console.log(`Student percentage: ${convertStudents}%`); | ||
| console.log(`Mentor percentage: ${convertMentors}%`); | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,25 @@ | ||
| function halve(number) { | ||
| // complete the function here | ||
| // function halve(number) { | ||
| // return number/2; | ||
| // } | ||
|
|
||
| // var result = halve(12); | ||
| // var result1 = halve(20); | ||
| // var result2 = halve(30); | ||
| // var result3 = halve(100); | ||
|
|
||
| // console.log(result); | ||
| // console.log(result1); | ||
| // console.log(result2); | ||
| // console.log(result3); | ||
|
|
||
| function divide(number) { | ||
| return number / 2; | ||
| } | ||
|
|
||
| var result = halve(12); | ||
| var answer1 = divide(5); | ||
| var answer2 = divide(10); | ||
| var answer3 = divide(15); | ||
|
|
||
| console.log(result); | ||
| console.log(answer1); | ||
| console.log(answer2); | ||
| console.log(answer3); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,16 @@ | ||
| function triple(number) { | ||
| // complete function here | ||
| // function triple(number) { | ||
| // return number*3 | ||
| // } | ||
|
|
||
| // var result = triple(12); | ||
|
|
||
| // console.log(result); | ||
|
|
||
| // My copy. | ||
| function threeTimes(number) { | ||
| return (number * 3)*3; | ||
| } | ||
|
|
||
| var result = triple(12); | ||
| var answer = threeTimes(3); | ||
|
|
||
| console.log(result); | ||
| console.log(`The answer is ${answer}`) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,19 @@ | ||
| // Complete the function so that it takes input parameters | ||
| function multiply() { | ||
| // Calculate the result of the function and return it | ||
| // function multiply(num1, num2) { | ||
| // return num1*num2; // Calculate the result of the function and return it | ||
| // } | ||
|
|
||
| // // Assign the result of calling the function the variable `result` | ||
| // var result = multiply(3, 4); | ||
|
|
||
| // console.log(result); | ||
|
|
||
| // My copy. | ||
| function multiply(num1, num2) { | ||
| return num1 * num2; | ||
| } | ||
|
|
||
| // Assign the result of calling the function the variable `result` | ||
| var result = multiply(3, 4); | ||
| let answer = multiply(5, 10); | ||
|
|
||
| console.log(answer); | ||
|
|
||
| console.log(result); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,16 @@ | ||
| // Declare your function first | ||
| // function divide(num1, num2){ | ||
| // return num1/num2; | ||
| // }// Declare your function first | ||
|
|
||
| var result = divide(3, 4); | ||
| // var result = divide(3, 4); | ||
|
|
||
| console.log(result); | ||
| // console.log(result); | ||
|
|
||
| // My copy. | ||
| function divide(num1, num2) { | ||
| return num1 / num2; | ||
| } | ||
|
|
||
| let answer = divide(5, 10); | ||
|
|
||
| console.log(Math.round(answer)); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,15 @@ | ||
| // Write your function here | ||
| // function createGreeting(name){ | ||
| // return `Hello, my name is ${name}`; | ||
| // }// Write your function here | ||
|
|
||
| var greeting = createGreeting("Daniel"); | ||
| // var greeting = createGreeting("Daniel"); | ||
|
|
||
| console.log(greeting); | ||
| // console.log(greeting); | ||
|
|
||
| function standardGreeting(firstName) { | ||
| return `Hello my firstname is ${firstName}` | ||
| } | ||
|
|
||
| let greeting = standardGreeting("Douglas"); | ||
|
|
||
| console.log(greeting); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,17 @@ | ||
| // Declare your function first | ||
| // function add(num1, num2) { | ||
| // return num1+num2; | ||
| // }// Declare your function first | ||
|
|
||
| // Call the function and assign to a variable `sum` | ||
| // var sum = add(13,124);// Call the function and assign to a variable `sum` | ||
|
|
||
| console.log(sum); | ||
| // console.log(sum); | ||
|
|
||
| // My Copy. | ||
|
|
||
| function adding(num1, num2) { | ||
| return num1 + num2; | ||
| } | ||
|
|
||
| let sum = adding(5, 10); | ||
|
|
||
| console.log(sum); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,16 @@ | ||
| // Declare your function here | ||
| // function createLongGreeting(name,age){ | ||
| // return`Hello, my name is ${name} and I'm ${age} years old` | ||
| // }// Declare your function here | ||
|
|
||
| const greeting = createLongGreeting("Daniel", 30); | ||
| // const greeting = createLongGreeting("Daniel", 30); | ||
|
|
||
| console.log(greeting); | ||
| // console.log(greeting); | ||
|
|
||
| // My copy. | ||
| function nameAgeGreeting(yourName, yourAge) { | ||
| return `My name is ${yourName} and I'm ${yourAge} years old.`; | ||
| } | ||
|
|
||
| let greeting = nameAgeGreeting("Douglas", 47); | ||
|
|
||
| console.log(greeting); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Douglas the expected results show 0.75 in the instructions and I see you using Math.round?
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.
Thank you Jontaz77 for your comment. I'll review it and make the necessary changes.