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
CAPE TOWN- CLASS 1 - SINOMBULELO_PUNGULA - JS_CORE_1 - WEEK_7 #60
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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,16 @@ | ||
| console.log("Hello world"); | ||
| console.log('Hello World, will this work?'); | ||
|
|
||
|
|
||
| //with multiple things | ||
|
|
||
| console.log('thing1', 'thing2'); //prints them both | ||
|
|
||
| //with no quotation marks | ||
|
|
||
| console.log(may produce an console.error); //produces an error | ||
|
|
||
|
|
||
| console.log(8); // produces a number | ||
|
|
||
|
|
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` | ||
|
|
||
| var greeting = 'Hello world!' | ||
| console.log(greeting); | ||
| console.log(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,6 @@ | ||
| // Start by creating a variable `message` | ||
| var message = 'Checking if this is a string'; | ||
| var messageType = typeof message; | ||
|
|
||
| console.log(message); | ||
| console.log(messageType); |
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` | ||
| var messageStart = 'Hello, my name is '; | ||
| var name = 'Sino'; | ||
|
|
||
| var message = messageStart + 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` | ||
|
|
||
| //var message = 'My name is'; | ||
| var myName = 'Sinombulelo'; | ||
| var myNameLength = myName.length; | ||
| var message = 'My name is ' + myName + ' and it is a whopping ' + myNameLength + ' letters long!'; | ||
| 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 @@ | ||
| const name = " Daniel "; | ||
| const myName = " Daniel "; | ||
| var nameTrim = myName.trim(); | ||
| var myNameLength = nameTrim.length; | ||
| var message = 'My name is ' + nameTrim + ' and it is a whopping ' + myNameLength + ' letters long!'; | ||
|
|
||
| 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 +1,10 @@ | ||
| // Start by creating a variables `numberOfStudents` and `numberOfMentors` | ||
| var numberOfStudents = 15; | ||
| var numberOfMentors = 8; | ||
|
|
||
| //var totalNumbers = numberOfMentors + numberOfStudents; | ||
|
|
||
|
|
||
|
|
||
| sum = numberOfStudents + numberOfMentors; | ||
| 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,2 +1,13 @@ | ||
| var numberOfStudents = 15; | ||
| var numberOfMentors = 8; | ||
| var totalNumber = numberOfStudents + numberOfMentors; | ||
|
|
||
| console.log(totalNumber); | ||
|
|
||
| percentageOfStudents = numberOfStudents * 100 / totalNumber; | ||
| percentageOfMentors = numberOfMentors * 100 / totalNumber; | ||
|
|
||
| console.log(Math.round(percentageOfStudents)); | ||
| console.log(Math.round(numberOfMentors)); | ||
|
|
||
|
|
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,12 @@ | ||
| function halve(number) { | ||
| // complete the function here | ||
| return number / 2; | ||
| } | ||
|
|
||
| var result = halve(12); | ||
| console.log(result); | ||
|
|
||
| var result = halve(20); | ||
| console.log(result); | ||
|
|
||
| var result = halve(6); | ||
| 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,7 +1,11 @@ | ||
| function triple(number) { | ||
| // complete function here | ||
| return number * 3; | ||
| } | ||
|
|
||
| var result = triple(12); | ||
|
|
||
| console.log(result); | ||
|
|
||
| var result = triple(3); | ||
| 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
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 divide(a, b) { | ||
| return a / b; | ||
| } | ||
| var result = divide(3, 4); | ||
|
|
||
| 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,7 @@ | ||
| // Write your function here | ||
|
|
||
| function createGreeting(name) { | ||
| return "Hello, my name is " + name; | ||
| } | ||
| var greeting = createGreeting("Daniel"); | ||
|
|
||
| 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,9 @@ | ||
| // Declare your function first | ||
|
|
||
| function add(a, b) { | ||
| return a + b; | ||
| } | ||
| // Call the function and assign to a variable `sum` | ||
|
|
||
| var sum = add(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,17 @@ | ||
| var mentor1 = "Daniel"; | ||
| var mentor2 = "Irina"; | ||
| var mentor3 = "Mimi"; | ||
| var mentor4 = "Rob"; | ||
| var mentor5 = "Yohannes"; | ||
| var mentor1 = greeting("Daniel"); | ||
| var mentor2 = greeting("Irina"); | ||
| var mentor3 = greeting("Mimi"); | ||
| var mentor4 = greeting("Rob"); | ||
| var mentor5 = greeting("Yohannes"); | ||
|
|
||
| function greeting(name) { | ||
| return 'HELLO ' + name.toUpperCase(); | ||
| } | ||
|
|
||
| console.log(mentor1); | ||
| console.log(mentor2); | ||
| console.log(mentor3); | ||
| console.log(mentor4); | ||
| console.log(mentor5); | ||
|
|
||
|
|
||
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 |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
|
|
||
|
|
||
| function percentage(numOfPeople, totalNumOfPeople) { | ||
| return Math.round((numOfPeople * 100 / totalNumOfPeople)); | ||
| } | ||
|
|
||
|
|
||
| var percentageStudents = percentage(15,23); | ||
| var percentageMentors = percentage(8, 23); | ||
|
|
||
| function message() { | ||
| return(`Percentage Students: ${percentageStudents} | ||
| Percentage Mentors: ${percentageMentors}`); | ||
| } | ||
|
|
||
| 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
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
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.
you didnt have to redeclare the variables