-
-
Notifications
You must be signed in to change notification settings - Fork 475
ZA2-Catalina-Alexandra Jora/ JavaScript-Core-1-Coursework-week1 #290
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,4 @@ | ||
| console.log("Hello world"); | ||
| console.log('Hello world'); | ||
| console.log("hello there!!!"); | ||
| console.log("finally working!"); | ||
| console.log("not working"); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| // Start by creating a variable `greeting` | ||
|
|
||
| console.log(greeting); | ||
| let greeting = "Isn't good day at all!" | ||
| console.log(greeting); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| // Start by creating a variable `message` | ||
| var message = "This is a string string" | ||
|
|
||
| console.log(message); | ||
| var messageType = typeof message; | ||
|
|
||
| console.log(messageType); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| // Start by creating a variable `message` | ||
|
|
||
| var greeting = "Good day, my name is "; | ||
| var myName = "Catalina"; | ||
| var message = greeting + myName; | ||
| console.log(message); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,8 @@ | ||
| // Start by creating a variable `message` | ||
| var message1 = "My name is Catalina-Alexandra and my name is "; | ||
| var message2 = " characters long"; | ||
| var myName = "Catalina-Alexandra"; | ||
| var nameLength = myName.length; | ||
| var message = message1 + nameLength + message2; | ||
|
|
||
| console.log(message); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,11 @@ | ||
| const name = " Daniel "; | ||
| const myName = " Catalina-Alexandra "; | ||
| const trimmed = myName.trim(); | ||
| var message1 = "My name is "; | ||
| var message2 = " and my name is "; | ||
| var message3 = " characters long"; | ||
|
|
||
| var nameLength = myName.length; | ||
| var message = message1 + trimmed + message2 + nameLength + message3; | ||
|
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. I am just suggesting a shorter way, you could have written this, however all the variables may have made it clearer. for the trimmed one u could have put myName.trim straight into the message statement. Also u could maybe have just used variables for things that may change. But what u did is also not wrong. Here is just another alternative. var message = "My name is" + myName.trim + " and my name is " + myName.length + "characters long"; |
||
|
|
||
|
|
||
| console.log(message); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,7 @@ | ||
| // Start by creating a variables `numberOfStudents` and `numberOfMentors` | ||
| var numberOfStudents = 30 + 2; | ||
| var numberOfMentors = 8 + 1; | ||
| var total = numberOfStudents + numberOfMentors; | ||
| console.log("Number of students: " + numberOfStudents); | ||
| console.log("Number of mentors: " + numberOfMentors); | ||
| console.log("Total number of students and mentors: " + total); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,9 @@ | ||
| var numberOfStudents = 15; | ||
| var numberOfMentors = 8; | ||
| var proNrOfStudents = 1500 / 23; | ||
| var proNrOfMentors = 800 / 23; | ||
| var proNrOfStudentsRound = Math.round(proNrOfStudents); | ||
| var proNrOfMentorsRound = Math.round(proNrOfMentors); | ||
|
|
||
| console.log("Procent of students: " + proNrOfStudentsRound + "%"); | ||
| console.log("Procent of mentors: " + proNrOfMentorsRound + "%"); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,8 @@ | ||
| function halve(number) { | ||
| // complete the function here | ||
| return number / 2; | ||
| } | ||
|
|
||
| var result = halve(12); | ||
| var result = halve(200); | ||
|
|
||
| console.log(result); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,8 @@ | ||
| function triple(number) { | ||
| // complete function here | ||
| return number * 3; | ||
| } | ||
|
|
||
| var result = triple(12); | ||
| var result = triple(7); | ||
|
|
||
| console.log(result); |
| 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); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| // Write your function here | ||
| function createGreeting(myName) { | ||
| return "Hello, my name is " + myName; | ||
| } | ||
|
|
||
| var greeting = createGreeting("Daniel"); | ||
| var greeting = createGreeting("Catalina"); | ||
|
|
||
| console.log(greeting); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| // Declare your function first | ||
| function addition(nr1, nr2) { | ||
| return nr1 + nr2; | ||
| } | ||
|
|
||
| // Call the function and assign to a variable `sum` | ||
|
|
||
| var sum = addition(13, 124); | ||
| console.log(sum); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| // Declare your function here | ||
| function createLongGreeting(myName, age) { | ||
| return "Hello, my name is " + myName + " and I'm " + age + " years old." | ||
| } | ||
|
|
||
| const greeting = createLongGreeting("Daniel", 30); | ||
| const greeting = createLongGreeting("Catalina", 47); | ||
|
|
||
| console.log(greeting); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,3 +3,18 @@ var mentor2 = "Irina"; | |
| var mentor3 = "Mimi"; | ||
| var mentor4 = "Rob"; | ||
| var mentor5 = "Yohannes"; | ||
|
|
||
| function upCase(name) { | ||
| return name.toUpperCase(); | ||
| } | ||
| function greeting(name) { | ||
| let shouty = upCase(name); | ||
| let message = "GOOD DAY " + shouty; | ||
| return message; | ||
| } | ||
| console.log(greeting(mentor1)); | ||
| console.log(greeting(mentor2)); | ||
| console.log(greeting(mentor3)); | ||
| console.log(greeting(mentor4)); | ||
| console.log(greeting(mentor5)); | ||
|
|
||
|
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 simple way of doing this project. Just suggesting alternatives, all the console.logs could have been done in the greeting as well but well done. |
||
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.
Hi Alex,
With this exercise I believe the aim was to print it 3 times. From this I understand you should have had 3 console.log greetings?
I hope the day went better after :)