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
London9 - Turing - Ying Xing - JavaScript-Core-1-Coursework-Week1 #455
Open
LexiisYing
wants to merge
6
commits into
CodeYourFuture:master
Choose a base branch
from
LexiisYing:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
098a5ae
fixed syntax errors 1
LexiisYing e30ccb0
fixed logic error
LexiisYing c311874
function output completed
LexiisYing 4abaeab
completed tax
LexiisYing 60fa6d6
exercises completed
LexiisYing 2977857
fixed J-functions exercises 2
LexiisYing 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
Binary file not shown.
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,7 @@ | ||
| console.log("Hello world"); | ||
| console.log("Hello world. I just started learning JavaScript") | ||
| console.log("what happens when i get rid of the quote marks?") | ||
| console.log("syntax error will occur") | ||
| console.log(7) | ||
| console.log('it logs the 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,5 @@ | ||
| // Start by creating a variable `greeting` | ||
|
|
||
| let 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` | ||
|
|
||
| console.log(message); | ||
| let message='lexi was doing the exercises' | ||
| let type=typeof message; | ||
| console.log(message) | ||
| console.log(type); |
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` | ||
|
|
||
| console.log(message); | ||
| let firstName='lexi ' | ||
| let lastName='Xing' | ||
| console.log(firstName + lastName); |
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` | ||
| let name ="lexi"; | ||
| let nameLength = name.length; | ||
|
|
||
| console.log(message); | ||
| console.log(name + nameLength); |
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 "; | ||
| const nameTrim=name.trim(); | ||
|
|
||
| console.log(message); | ||
| console.log(nameTrim); |
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,5 @@ | ||
| // Start by creating a variables `numberOfStudents` and `numberOfMentors` | ||
| let numberOfStudents=15; | ||
| let numberOfMentors=8; | ||
| let total=numberOfMentors + numberOfStudents; | ||
| console.log(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,9 @@ | ||
| var numberOfStudents = 15; | ||
| var numberOfMentors = 8; | ||
| var total=numberOfMentors + numberOfStudents; | ||
| var numberOfMen=Math.round((numberOfMentors/total)*100); | ||
| let perOfMen=numberOfMen + `%`; | ||
| var numberOfStu=Math.round((numberOfStudents/total)*100); | ||
| let perOfStu=numberOfStu + `%`; | ||
| console.log(perOfMen); | ||
| console.log(perOfStu); |
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,6 @@ | ||
| 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,7 +1,10 @@ | ||
| function triple(number) { | ||
| // complete function here | ||
| return number * 3; | ||
| } | ||
|
|
||
| var result = triple(12); | ||
|
|
||
| var result1 = triple(6); | ||
| var result = triple(2); | ||
| console.log(result1); | ||
| 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 ('nice to meet you ' + 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,7 @@ | ||
| // Declare your function first | ||
|
|
||
| function summed(a,b) { | ||
| return a+b | ||
| } | ||
| // Call the function and assign to a variable `sum` | ||
|
|
||
| let sum = summed(13 + 24) | ||
| 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,4 +1,9 @@ | ||
| // Declare your function here | ||
| function createLongGreeting(name,age){ | ||
| return `hello my name is ${name} and i'm ${age} years old`; | ||
|
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. Great use of a template string |
||
| } | ||
|
|
||
|
|
||
|
|
||
| const greeting = createLongGreeting("Daniel", 30); | ||
|
|
||
|
|
||
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,60 @@ | ||
|
|
||
|
|
||
|
|
||
| /*function moodChecker(mood) { | ||
| if (mood === "Happy") { | ||
| return 'good job, you are doing great'; | ||
|
|
||
| } else if (mood === "sad") { | ||
| return "every cloud has a silver lining"; | ||
| } else if (typeof mood === "number") { | ||
| return "beep beep boop"; | ||
| } else { | ||
| return "i'm sorry, i'm still learning about feelings" | ||
| } | ||
| } | ||
| */ | ||
|
|
||
|
|
||
| // console.log(moodChecker("hmm")); | ||
|
|
||
| // && and | ||
| // || or | ||
| // ! not | ||
|
|
||
| function checkUsername(userName, userType) { | ||
| if (userType === "admin" || userType === "manager") { | ||
| return "username valid" | ||
| } | ||
| else if (userName(0) === userName(0).toUpperCase() && userName.length >5 | ||
| && userName <10 ) { | ||
| return "username valid"; | ||
| } else { | ||
| return "username invalid"; | ||
| } | ||
| } | ||
|
|
||
| console.log(checkUsername("lexi", "admin")); | ||
|
|
||
| const fruits = ['banana', 'apple', 'strawberry', 'kiwi', 'fig', 'orange']; | ||
| console.log(fruits[2], fruits[3]); | ||
|
|
||
| /*function lastTask (tasks) { | ||
| console.log(tasks[2]); | ||
| console.log(tasks.length); | ||
| return `don't forget to ${tasks[2].toUpperCase()}` | ||
| } | ||
|
|
||
|
|
||
|
|
||
| let tasks =['do the dishes', 'take out garbage', 'practice coding']; | ||
| console.log(lastTask(tasks)); */ | ||
|
|
||
| function randomTask(tasks) { | ||
|
|
||
| } | ||
|
|
||
| let tasks = ['do the dishes', 'take out garbage', | ||
| 'practice coding', 'clean house']; | ||
| console.log(randomTask['do the dishes', 'take out garbage', | ||
| 'practice coding', 'clean house']); |
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,18 @@ | ||
| var mentor1 = "Daniel"; | ||
| var mentor1 = "Daniel! "; | ||
| var mentor2 = "Irina"; | ||
| var mentor3 = "Mimi"; | ||
| var mentor4 = "Rob"; | ||
| var mentor5 = "Yohannes"; | ||
| function nameUpperCase (name) { | ||
| return name.toUpperCase(); | ||
| } | ||
|
|
||
| function greetingMentors (name) { | ||
| return `hello ${nameUpperCase(name)}`; | ||
| } | ||
|
|
||
| console.log(greetingMentors(mentor1)); | ||
| console.log(greetingMentors(mentor2)); | ||
| console.log(greetingMentors(mentor3)); | ||
| console.log(greetingMentors(mentor4)); | ||
| console.log(greetingMentors(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 |
|---|---|---|
|
|
@@ -3,14 +3,24 @@ function getRandomNumber() { | |
| return Math.random() * 10; | ||
| } | ||
|
|
||
| // The Math object in JavaScript is a built-in object that has properties and methods for performing mathematical calculations. | ||
| // A common use of the Math object is to create a random number using the random() method. | ||
|
|
||
| // Add comments to explain what this function does. You're meant to use Google! | ||
| function combine2Words(word1, word2) { | ||
| return word1.concat(word2); | ||
| } | ||
|
|
||
| //The concat() method joins two or more strings. | ||
|
|
||
| //The concat() method does not change the existing strings. | ||
|
|
||
| //The concat() method returns a new string. | ||
|
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. 👍 |
||
|
|
||
| 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.concat(' ', 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 works fine, but if the value of
greetingwill only be set once and not changed later,constis better thanlet