-
-
Notifications
You must be signed in to change notification settings - Fork 195
WM | ITP-Jan25 | Hatef Eidi | Module Strcturing and Testing Data | Sprint-1 #263
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
base: main
Are you sure you want to change the base?
Changes from all commits
9dfbf61
2ae38e4
f4fdf3c
5bbeaa1
04e19e6
26ed136
5302827
9b1a1cb
61dbd1b
1a13889
70b0824
1848c74
e4d0f87
dffe519
110186e
5697536
22e82d7
28e796a
83efda8
b5c7e0f
e07ec38
6c29b81
6424450
1ebe900
6dc8e67
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,5 @@ | ||
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? | ||
|
||
|
||
//we should comment them out, in VS Code the shourtcut is cntrl + c, cntrl + k. the symple of commenting out for each coding language differs and computers don't execute the lines that are commented out |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
// trying to create an age variable and then reassign the value by 1 | ||
|
||
const age = 33; | ||
let age = 33; | ||
age = age + 1; | ||
|
||
console.log(age); | ||
|
||
//In this case we cann't use const variable if we want to change its value later on, so it should be let |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
// Currently trying to print the string "I was born in Bolton" but it isn't working... | ||
// what's the error ? | ||
|
||
console.log(`I was born in ${cityOfBirth}`); | ||
const cityOfBirth = "Bolton"; | ||
console.log(`I was born in ${cityOfBirth}`); | ||
|
||
//The error was Referrence Error which is cause by using a variable before declaring it. JavaScript reads from top to bottom, so we have to declare the variable first and the use it. I moved the cityOfBirth variable one line above the console.log funciton |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
const cardNumber = 4533787178994213; | ||
const last4Digits = cardNumber.slice(-4); | ||
const lastFourDigits = String(cardNumber).slice(-4); | ||
|
||
console.log(lastFourDigits); | ||
|
||
// The last4Digits variable should store the last 4 digits of cardNumber | ||
// However, the code isn't working | ||
// Before running the code, make and explain a prediction about why the code won't work | ||
// Then run the code and see what error it gives. | ||
// Consider: Why does it give this error? Is this what I predicted? If not, what's different? | ||
// Then try updating the expression last4Digits is assigned to, in order to get the correct value | ||
|
||
|
||
//Prediction and explaination: | ||
//index value is only for string and array data types, in this case it throws an error since cardNumber holds a number not string or arrray. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
const 12HourClockTime = "20:53"; | ||
const 24hourClockTime = "08:53"; | ||
const twelveHourClockTime = "20:53"; | ||
const twentyFourHourClockTime = "08:53"; | ||
|
||
//Answer: we can declare or name our variables using numeric values, but we can't start with a number, so we can't name our variables as 20:53 or 08:53 | ||
// Furthermore, the variable's name doesn't match the content of the variables and the naming should be opposite, to match the content of the values. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,15 @@ In the Chrome console, | |
invoke the function `alert` with an input string of `"Hello world!"`; | ||
|
||
What effect does calling the `alert` function have? | ||
A pop-up box will appear with the text of Hello world! | ||
|
||
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`. | ||
|
||
What effect does calling the `prompt` function have? | ||
A pop-up box will appear with the text what is your name? and input text box to let the user type their names | ||
If they press cancel, whether or not they have entered their name in the text box- in the console we will see the 'null' in the next line of the prompt | ||
If they enter their name, and press ok, in the console they can view their name. | ||
|
||
What is the return value of `prompt`? | ||
The input of the what is your name pop-up text | ||
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 were writing a program that uses 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 they press cancel, whether or not they have entered their name in the text box- in the console we will see the 'null' in the next line of the prompt 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 if the user entered "null" and pressed ok? 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 will return the string of null which is the input=> 'null' |
||
If they enter their name, and press ok, in the console they can view their name. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
console.log("Hello, this is my JavaScript file!"); | ||
console.log("Node.js is executing this file."); |
Uh oh!
There was an error while loading. Please reload this page.