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
London Class 7 - Hozan Ali - JavaScript-Core-1-Coursework - Week 1 #52
Closed
Closed
Changes from all commits
Commits
Show all changes
3 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,14 @@ | ||
| console.log("Hello world"); | ||
|
|
||
| console.log("Hello world. I just started learning JavaScript!"); | ||
|
|
||
| console.log("JavaScript is challenging but it is fun"); | ||
|
|
||
| console.log("You need to practices regularly"); | ||
|
|
||
| // This will throw an error | ||
| // console.log(Hozan Ali) | ||
|
|
||
| console.log(2021); | ||
|
|
||
| console.log(2022); |
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,5 @@ | ||
| // Start by creating a variable `message` | ||
| var message = "This is a string"; | ||
|
|
||
| console.log(message); | ||
| console.log(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` | ||
| var greetingMessage = "Hello, my name is "; | ||
| var myName = "Hozan"; | ||
| var message = greetingMessage + myName; | ||
|
|
||
| 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 myName = "Hozan"; | ||
| var nameLength = myName.length; | ||
| var message = "My name is " + myName + " and my name is " + nameLength + " 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,3 +1,4 @@ | ||
| const name = " Daniel "; | ||
| var message = "My name is " + name.trim() + " and my name is " + name.trim().length + " 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,8 @@ | ||
| // Start by creating a variables `numberOfStudents` and `numberOfMentors` | ||
| let numberOfStudents = 15; | ||
| let numberOfMentors = 8; | ||
| let sumOfParticipants = numberOfStudents + numberOfMentors; | ||
|
|
||
| console.log("Number of students: " + numberOfStudents); | ||
| console.log("Number of mentors: " + numberOfMentors); | ||
| console.log("Total number of students and mentors: " + sumOfParticipants); |
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,9 @@ | ||
| var numberOfStudents = 15; | ||
| var numberOfMentors = 8; | ||
| var total = numberOfStudents + numberOfMentors; | ||
|
|
||
| var percentageOfStudents = Math.round((numberOfStudents / total) * 100) + "%"; | ||
| var percentageOfMentors = Math.round((numberOfMentors / total) * 100) + "%"; | ||
|
|
||
| console.log("Percentage of students: " + percentageOfStudents); | ||
| console.log("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,7 +1,12 @@ | ||
| function halve(number) { | ||
| // complete the function here | ||
| return number / 2; | ||
| } | ||
|
|
||
| var result = halve(12); | ||
| console.log(result); | ||
|
|
||
| result = halve(20); | ||
| console.log(result); | ||
|
|
||
| result = halve(22); | ||
| 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,9 @@ | ||
| function triple(number) { | ||
| // complete function here | ||
| return number * 3; | ||
| } | ||
|
|
||
| var result = triple(12); | ||
| console.log(result); | ||
|
|
||
| result = triple (15); | ||
| 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,9 +1,8 @@ | ||
| // 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; | ||
| } | ||
|
|
||
| // Assign the result of calling the function the variable `result` | ||
| var result = multiply(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,4 +1,7 @@ | ||
| // 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,8 @@ | ||
| // Declare your function first | ||
|
|
||
| function addNum(num1, num2){ | ||
| return num1 + num2; | ||
| } | ||
| // Call the function and assign to a variable `sum` | ||
| var sum = addNum(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,12 @@ | ||
| var mentor1 = "Daniel"; | ||
| var mentor2 = "Irina"; | ||
| var mentor3 = "Mimi"; | ||
| var mentor4 = "Rob"; | ||
| var mentor5 = "Yohannes"; | ||
| function percentage(number, total){ | ||
| return Math.round((number / total) * 100); | ||
| }; | ||
|
|
||
|
|
||
| function getResults(type, number, total){ | ||
| var getPercentage = percentage(number, total); | ||
| return `Percentage ${type}: ${getPercentage}%`; | ||
| }; | ||
|
|
||
| console.log(getResults("students",15,23)); | ||
| console.log(getResults("mentors",8,23)); |
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,20 @@ | ||
| var mentor1 = "Daniel"; | ||
| var mentor2 = "Irina"; | ||
| var mentor3 = "Mimi"; | ||
| var mentor4 = "Rob"; | ||
| var mentor5 = "Yohannes"; | ||
|
|
||
| function capitalName(name){ | ||
| return name.toUpperCase(); | ||
| }; | ||
|
|
||
| function shoutyGreeting(greeting, name){ | ||
| var getCapitalName = capitalName(name); | ||
| return `${greeting.toUpperCase()} ${getCapitalName}`; | ||
| }; | ||
|
|
||
| console.log(shoutyGreeting("hello",mentor1)); | ||
| console.log(shoutyGreeting("hello",mentor2)); | ||
| console.log(shoutyGreeting("hello",mentor3)); | ||
| console.log(shoutyGreeting("hello",mentor4)); | ||
| console.log(shoutyGreeting("hello",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
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,16 +1,19 @@ | ||
| // Add comments to explain what this function does. You're meant to use Google! | ||
| function getNumber() { | ||
| return Math.random() * 10; | ||
| return Math.random() * 10; | ||
| } | ||
| // The function above will return a random floating point between 0 and 10 (not included), The random() method returns a random floating number from 0 (inclusive) up to but not including 1 (exclusive) | ||
|
|
||
|
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 Hozan, when if you run
Author
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 @louisechow , many thanks for the feedback. |
||
| // Add comments to explain what this function does. You're meant to use Google! | ||
| function s(w1, w2) { | ||
| return w1.concat(w2); | ||
| } | ||
| // The concat() method above is used to join or concatenate the two parameters W1 and W2, so the function will return a new string of w1 + w2. | ||
|
|
||
| function concatenate(firstWord, secondWord, thirdWord) { | ||
| // 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. | ||
| return `${firstWord} ${secondWord} ${thirdWord}`; | ||
| } | ||
|
|
||
| /* | ||
|
|
||
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.
This looks great Hozan! As a challenge, you can make use of template literals. This link: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals and video: https://youtu.be/NgF9-pdTDGs are quite useful should you need them.
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.
Thanks for the feedback Omar, the documents you provided looks great, I already went through them and found some useful info, I want to also note that in some exercises I did apply template literals, while in others I left them to have string literlas just so I practice how to use them both. Many Thanks