-
-
Notifications
You must be signed in to change notification settings - Fork 475
GLASGOW_CLASS_5_OMER_ALI_WEEK_1 #176
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 |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| // Use IntelliSense to learn about possible attributes. | ||
| // Hover to view descriptions of existing attributes. | ||
| // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
| "version": "0.2.0", | ||
| "configurations": [ | ||
| { | ||
| "type": "pwa-node", | ||
| "request": "launch", | ||
| "name": "Launch Program", | ||
| "skipFiles": [ | ||
| "<node_internals>/**" | ||
| ], | ||
| "program": "${workspaceFolder}/exercises/B-hello-world/exercise.js" | ||
| } | ||
| ] | ||
| } |
| 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!"); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| // Start by creating a variable `greeting` | ||
|
|
||
| let greeting = "Hello"; | ||
| console.log(greeting); | ||
|
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. You have declared and used the variable correctly however we also want you to print it three times. You could do this using a |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,22 @@ | ||
| // Start by creating a variable `message` | ||
|
|
||
| console.log(message); | ||
| let messageChoice = 0; | ||
| let messageType; | ||
| let message = ""; | ||
|
|
||
| messageChoice = Math.round(Math.random() * 2); | ||
|
|
||
|
|
||
| if (messageChoice == 0) { | ||
| message = "This is a 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. If you have a variable like For example |
||
| } else if (messageChoice == 1) { | ||
| message = 25.5; | ||
| } else { | ||
| message = true; | ||
| } | ||
|
|
||
|
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. It's really good to try out different things like you've done here as it definitely helps with understanding them better!! However, if you do this you can also put it in a separate file just in case it interferes with the assigned task. |
||
| messageType = typeof message; | ||
|
|
||
| console.log(` | ||
| ${message} | ||
| ${messageType}`); | ||
|
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. Excellent. Good to try out string interpolation as a way of outputting variables. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,9 @@ | ||
| // Start by creating a variable `message` | ||
|
|
||
| console.log(message); | ||
| const MY_NAME = "Omer"; | ||
| let greetingStart = "Hello, my name is "; | ||
| let greeting = ""; | ||
|
|
||
| greeting = greetingStart + MY_NAME; | ||
|
|
||
| console.log(greeting); | ||
|
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. Excellent. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,13 @@ | ||
| // Start by creating a variable `message` | ||
| const MY_NAME = "Omer"; | ||
| const NAME_LENGTH = MY_NAME.length; | ||
| let message = ""; | ||
|
|
||
| // Update Message & output message | ||
| message = | ||
| "My name is " + | ||
| MY_NAME + | ||
| " and my name is " + | ||
| NAME_LENGTH + | ||
| " characters long"; | ||
| console.log(message); | ||
|
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. Excellent. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,14 @@ | ||
| // Start by creating a variables `numberOfStudents` and `numberOfMentors` | ||
| let numberOfStudents = 15; | ||
| let numberOfMentors = 8; | ||
| let totalStudentsAndMentors = 0; | ||
| let message = ""; | ||
|
|
||
| // Calculate total number of students | ||
| totalStudentsAndMentors = numberOfStudents + numberOfMentors; | ||
|
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. You can simplify this by initialising the variable and setting its value at the same time. I.e.:
(so you no longer need line 4) |
||
|
|
||
| // Concatenate string | ||
| message = `Number of students: ${numberOfStudents} | ||
| Number of mentors: ${numberOfMentors} | ||
| Total number of students and mentors: ${totalStudentsAndMentors}`; | ||
| console.log(message); | ||
|
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. Excellent. Again, you could do |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| function halve(number) { | ||
| // complete the function here | ||
| return (result = number / 2); | ||
| } | ||
|
|
||
| var result = halve(12); | ||
|
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. Excellent. |
||
|
|
||
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.
Excellent.