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
Birmingham Class 2 - Chizim Chinuru - JS-Core-1 - Week 1 #2
Closed
scarabeo7
wants to merge
8
commits into
CodeYourFuture:master
from
scarabeo7:ChizimChinuru-js-1-exercise
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
523e38b
going through exercises
scarabeo7 19ae449
completed exercises
scarabeo7 0efb649
corrected typo error
scarabeo7 d360383
added pounds to dollars converter
scarabeo7 787246d
best practice for piping functions
scarabeo7 b85cdce
done magic -8- ball exercise
scarabeo7 0292f7a
renamed variable in order to make more sense
scarabeo7 8446356
removed reduntant variable
scarabeo7 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 @@ | ||
| console.log("Hello world"); | ||
| console.log("Hello world I just started learning JavaScript!'."); |
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,3 @@ | ||
| // Start by creating a variable `greeting` | ||
|
|
||
| const greeting = "Hello world I just started learning JavaScript!"; | ||
| 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` | ||
| const message = "Hello world I just started learning JavaScript!"; | ||
| const 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,5 @@ | ||
| // Start by creating a variable `message` | ||
| const intro = "Hello, my name is"; | ||
| const name = "Chizim"; | ||
|
|
||
| console.log(message); | ||
| console.log(`${intro} ${name} and I like to code`); | ||
|
scarabeo7 marked this conversation as resolved.
|
||
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` | ||
|
|
||
| console.log(message); | ||
| const name = "Chizim"; | ||
| const nameLength = name.length; | ||
|
|
||
| console.log(`My name is ${name} 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,6 @@ | ||
| const name = " Daniel "; | ||
| const trimmedName = name.trim(); | ||
| const newNameLength = trimmedName.length; | ||
|
|
||
| console.log(`My name is ${trimmedName} and my name is ${newNameLength} characters 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` | ||
|
|
||
| const numberOfStudents = 15; | ||
| const numberOfMentors = 3; | ||
|
|
||
| const total = numberOfStudents + numberOfMentors; | ||
|
|
||
| console.log(`Number of students: ${numberOfStudents}`); | ||
| console.log(`Number of mentors: ${numberOfMentors}`); | ||
| console.log(`Total numnber 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; | ||
|
|
||
| var total = numberOfStudents + numberOfMentors; | ||
|
|
||
| // get percentage of students and mentors | ||
| var convertStudents = numberOfStudents / total * 100; | ||
| var convertMentors = numberOfMentors / total * 100; | ||
|
|
||
| // round the figues to a whole number | ||
| var percentageOfStudents = Math.round(convertStudents); | ||
| var percentageOfMentors = Math.round(convertMentors); | ||
|
|
||
| console.log(`Percentage students: ${percentageOfStudents}%`); | ||
| console.log(`Percentage students: ${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,7 +1,11 @@ | ||
| function halve(number) { | ||
| // complete the function here | ||
| return number / 2;// complete the function here | ||
| } | ||
|
|
||
| var result = halve(12); | ||
| var result1 = halve(10); | ||
| var result2 = halve(9); | ||
|
|
||
| console.log(result); | ||
| console.log(result1); | ||
| console.log(result2); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,10 @@ | ||
| // Declare your function first | ||
| function add (num1, num2) { | ||
| return num1 + num2; | ||
| } | ||
|
|
||
| // 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,39 @@ | ||
| function groupPercentage(num1, num2){ | ||
| let totalInGroup = num1 + num2; | ||
| return calculatePercentage = Math.round((num1 / totalInGroup) * 100); | ||
| } | ||
|
|
||
| function message(numberOfStudents, numberOfMentors){ | ||
| let percentageOfStudents = groupPercentage(numberOfStudents, numberOfMentors); | ||
| let percentageOfMentors = groupPercentage (numberOfMentors, numberOfStudents); | ||
| return `Percentage students: ${percentageOfStudents}%\nPercentage students: ${percentageOfMentors}%`; | ||
| } | ||
| let percentage = message(15, 8); | ||
| console.log(percentage); | ||
|
|
||
|
|
||
| // Exercise 2 | ||
|
|
||
| var mentor1 = "Daniel"; | ||
| var mentor2 = "Irina"; | ||
| var mentor3 = "Mimi"; | ||
| var mentor4 = "Rob"; | ||
| var mentor5 = "Yohannes"; | ||
|
|
||
| function shoutyGreeting(mentor){ | ||
| let blockNames = mentor.toUpperCase(); | ||
| return greeting = `HELLO ${blockNames}`; | ||
|
|
||
| } | ||
|
|
||
| var firstGreeting = shoutyGreeting(mentor1); | ||
| var secondGreeting = shoutyGreeting(mentor2); | ||
| var thirdGreeting = shoutyGreeting(mentor3); | ||
| var fourthGreeting = shoutyGreeting(mentor4); | ||
| var fifthGreeting = shoutyGreeting(mentor5); | ||
|
|
||
| console.log(firstGreeting); | ||
| console.log(secondGreeting); | ||
| console.log(thirdGreeting); | ||
| console.log(fourthGreeting); | ||
| console.log(fifthGreeting); |
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.
Uh oh!
There was an error while loading. Please reload this page.