-
-
Notifications
You must be signed in to change notification settings - Fork 336
Manchester| ITP-Jan-26 | Ofonime Edak | Sprint 1| Structuring and Testing Data #1052
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1c7d558
84027f2
63c55f5
ec16947
f76bcc1
789ad61
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,2 +1,2 @@ | ||
| This is just an instruction for the first activity - but it is just for human consumption | ||
| We don't want the computer to run these 2 lines - how can we solve this problem? | ||
| //This is just an instruction for the first activity - but it is just for human consumption | ||
| //We don't want the computer to run these 2 lines - how can we solve this problem? |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| // trying to create an age variable and then reassign the value by 1 | ||
|
|
||
| const age = 33; | ||
| let age = 33; | ||
| age = age + 1; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,9 @@ | ||
| // Currently trying to print the string "I was born in Bolton" but it isn't working... | ||
| // what's the error ? | ||
| // JavaScript is single-threaded because it executes tasks in a single flow using a call stack. The function was called before it was declared, | ||
| // It was also declared with const, which can not be hoisted to the top, like var. | ||
| // this result to undefined. | ||
|
|
||
| console.log(`I was born in ${cityOfBirth}`); | ||
| const cityOfBirth = "Bolton"; | ||
| console.log(`I was born in ${cityOfBirth}`); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| const 12HourClockTime = "20:53"; | ||
| const 24hourClockTime = "08:53"; | ||
| const twelveHourClockTime = "20:53"; | ||
| const twentyFourHourClockTime = "08:53"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,13 +6,20 @@ Voila! You now have access to the [Chrome V8 Engine](https://www.cloudflare.com/ | |
| Just like the Node REPL, you can input JavaScript code into the Console tab and the V8 engine will execute it. | ||
|
|
||
| Let's try an example. | ||
|
|
||
| In the Chrome console, | ||
| invoke the function `alert` with an input string of `"Hello world!"`; | ||
|
|
||
| It invokes the modal window and display Hello world | ||
|
|
||
| What effect does calling the `alert` function have? | ||
| It freezes the window till i click Ok before ii can make use of my computer | ||
|
|
||
| Now try invoking the function `prompt` with a string input of `"What is your name?"` - store the return value of your call to `prompt` in an variable called `myName`. | ||
| const myName=prompt(`"What is your name?"`) | ||
| return value myName=Edak | ||
|
|
||
| What effect does calling the `prompt` function have? | ||
| it invokes a modal window, and allows me to enter an input value | ||
| What is the return value of `prompt`? | ||
| it returns the value i entered "Edak" | ||
|
Comment on lines
23
to
+24
Contributor
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. What would the function return if you entered "Edak" and clicked "Cancel" instead of "OK"? |
||
| if "Edak" is entered an cancelled it returns null | ||
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
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.
Optional challenge:
Could we expect this program to work as intended for any valid
penceStringif we deleted.padEnd(2, "0")from the code?In other words, do we really need
.padEnd(2, "0")in this script?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.
We don't really need the .padEnd() at the end, as it helps only when the length of the string is less than 3
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.
How do you know if
paddedPenceNumberStringis guaranteed to have at least 3 character?