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 476
ZA2-Kwanda Silekwa-JavaScript-Core-1-Coursework-Week1 #299
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
87e953c
update
kwanda9700 ed55bf0
update
kwanda9700 215a352
update
kwanda9700 828c7f5
Update 2-piping.js
kwanda9700 8d56133
Update 3-magic-8-ball.js
kwanda9700 38f548c
Update package.json
kwanda9700 2572a77
update
kwanda9700 5b12896
update
kwanda9700 45bbd19
Update exercise.js
kwanda9700 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,2 @@ | ||
| console.log("Hello world"); | ||
| console.log("Hello World. I am Kwanda Silekwa"); |
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,6 @@ | ||
| // Start by creating a variable `greeting` | ||
| let greeting = "Hello World"; | ||
|
|
||
| console.log(greeting); | ||
| for (i = 1; i < 4; i++) { | ||
| 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,4 @@ | ||
| // Start by creating a variable `message` | ||
| let message = "This is a string"; | ||
|
|
||
| console.log(message); | ||
| console.log(message + "\n" + typeof message); |
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,6 @@ | ||
| // Start by creating a variable `message` | ||
| let greetingStart = "Hello, my name is "; | ||
| let name_ = "Daniel"; | ||
|
|
||
| let message = greetingStart + name_; | ||
| console.log(message); |
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,6 @@ | ||
| // Start by creating a variable `message` | ||
| let greeting = "Hello, my name is Daniel"; | ||
| const name_ = "Daniel"; | ||
| let nameLength = name_.length; | ||
|
|
||
| console.log(message); | ||
| console.log(greeting + " and my name is " + nameLength + " 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,5 @@ | ||
| const name = " Daniel "; | ||
| let greeting = "Hello, my name is Daniel"; | ||
| const name_ = "Daniel".trim(); | ||
| let nameLength = name_.length; | ||
|
|
||
| console.log(message); | ||
| console.log(greeting + " and my name is " + nameLength + " 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,15 @@ | ||
| // Start by creating a variables `numberOfStudents` and `numberOfMentors` | ||
| let numberOfStudents = 15; | ||
| let numberOfMentors = 8; | ||
| let total = numberOfStudents + numberOfMentors; | ||
|
|
||
| console.log( | ||
| "Number of students: " + | ||
| numberOfStudents + | ||
| "\n" + | ||
| "Number of mentors: " + | ||
| numberOfMentors + | ||
| "\n" + | ||
| "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,16 @@ | ||
| var numberOfStudents = 15; | ||
| var numberOfMentors = 8; | ||
| let total = numberOfStudents + numberOfMentors; | ||
|
|
||
| let percentageOfStudents = Math.round((numberOfStudents / total) * 100); | ||
| let percentageOfMentors = Math.round((numberOfMentors / total) * 100); | ||
|
|
||
| console.log( | ||
| "Percentage of students: " + | ||
| percentageOfStudents + | ||
| "%" + | ||
| "\n" + | ||
| "Percentage of mentors: " + | ||
| percentageOfMentors + | ||
| "%" | ||
| ); |
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,5 @@ | ||
| function halve(number) { | ||
| // complete the function here | ||
| return number / 2; | ||
| } | ||
|
|
||
| var result = halve(12); | ||
|
|
||
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,5 @@ | ||
| function triple(number) { | ||
| // complete function here | ||
| return number * 3; | ||
| } | ||
|
|
||
| var result = triple(12); | ||
|
|
||
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,4 +1,6 @@ | ||
| // Declare your function first | ||
| function divide(num1, num2) { | ||
| return num1 / num2; | ||
| } | ||
|
|
||
| var result = divide(3, 4); | ||
|
|
||
|
|
||
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,5 +1,7 @@ | ||
| // Declare your function first | ||
| function sum(num1, num2) { | ||
| return num1 + num2; | ||
| } | ||
|
|
||
| // Call the function and assign to a variable `sum` | ||
| var sum = sum(13, 124); | ||
|
|
||
| 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
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,29 @@ | ||||||||||
| function shoutyGreeting(str) { | ||||||||||
|
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. The exercise requires two functions, one that spells their names in uppercase, and one that create a shouty greeting.
Suggested change
|
||||||||||
| greeting = "Hello " + str; | ||||||||||
| return greeting.toUpperCase(); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| var mentor1 = "Daniel"; | ||||||||||
| var mentor2 = "Irina"; | ||||||||||
| var mentor3 = "Mimi"; | ||||||||||
| var mentor4 = "Rob"; | ||||||||||
| var mentor5 = "Yohannes"; | ||||||||||
|
|
||||||||||
| for (x = 1; x < 6; x++) { | ||||||||||
| if (x == 1) { | ||||||||||
| var greeting = shoutyGreeting(mentor1); | ||||||||||
| console.log(greeting); | ||||||||||
| } else if (x == 2) { | ||||||||||
| var greeting = shoutyGreeting(mentor2); | ||||||||||
| console.log(greeting); | ||||||||||
| } else if (x == 3) { | ||||||||||
| var greeting = shoutyGreeting(mentor3); | ||||||||||
| console.log(greeting); | ||||||||||
| } else if (x == 4) { | ||||||||||
| var greeting = shoutyGreeting(mentor4); | ||||||||||
| console.log(greeting); | ||||||||||
| } else if (x == 5) { | ||||||||||
| var greeting = shoutyGreeting(mentor5); | ||||||||||
| 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
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
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
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
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.
Great use of a for loop to perform a repetitive task 👍