-
-
Notifications
You must be signed in to change notification settings - Fork 275
London | 25-ITP-Sep | Payman Issa Baiglu | Sprint 1 | Coursework/sprint 1 #811
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
c16f93f
baf6383
a1bcfd7
8ddf08f
74687a6
8257fa0
2a33fa1
870693a
f8a6510
bc21da9
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 |
|---|---|---|
|
|
@@ -17,7 +17,11 @@ console.log(`The base part of ${filePath} is ${base}`); | |
| // Create a variable to store the dir part of the filePath variable | ||
| // Create a variable to store the ext part of the variable | ||
|
|
||
| const dir = ; | ||
| const ext = ; | ||
| const dir = filePath.slice(0, lastSlashIndex + 1); | ||
|
|
||
| const lastSlDotIndex = filePath.lastIndexOf("."); | ||
|
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. In the variable name,
Author
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 think it comes from Slice.
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. Variable names should be meaningful. What are you trying to describe as
Author
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 would say it means the last slice after "." |
||
| const ext = filePath.slice(lastSlDotIndex); | ||
|
|
||
| console.log(`The dir part of ${filePath} is ${dir}`); | ||
| console.log(`The ext part of ${filePath} is ${ext}`); | ||
| // https://www.google.com/search?q=slice+mdn | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,4 @@ | ||
| 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 need to add double "//" at the start of the line so computer will ignore this line. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| // trying to create an age variable and then reassign the value by 1 | ||
|
|
||
| const age = 33; | ||
| // const age = 33; age should be defined as let so it can get different values. | ||
| let age = 33 | ||
| age = age + 1; | ||
| console.log(age); |
| 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 ? | ||
| // any variable must be defined first and then can be used. | ||
|
|
||
| console.log(`I was born in ${cityOfBirth}`); | ||
| const cityOfBirth = "Bolton"; | ||
| console.log(`I was born in ${cityOfBirth}`); | ||
| // const cityOfBirth = "Bolton"; => Wrong place! |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,17 @@ | ||
| const cardNumber = 4533787178994213; | ||
| const last4Digits = cardNumber.slice(-4); | ||
|
|
||
| const last4Digits = cardNumber.toString().slice(-4); | ||
|
|
||
| // 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 | ||
|
|
||
|
|
||
|
|
||
| //.Slice() is for strings but here we have 1 number here. so we need to make that number a string by putting it in a "". or using .toString() to change any input to string type. | ||
|
|
||
|
|
||
| console.log(last4Digits); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,7 @@ | ||
| const 12HourClockTime = "20:53"; | ||
| const 24hourClockTime = "08:53"; | ||
| //const 12HourClockTime = "20:53"; | ||
| //const 24hourClockTime = "08:53"; | ||
|
|
||
| // An identifier or keyword cannot immediately follow a numeric literal. | ||
|
|
||
| const ClockTime24Hour = "20:53"; | ||
| const ClockTime12hour = "08:53"; | ||
cjyuan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,8 +11,10 @@ In the Chrome console, | |
| invoke the function `alert` with an input string of `"Hello world!"`; | ||
|
|
||
| What effect does calling the `alert` function have? | ||
| "Hello world!" will be printed in a pop up box. | ||
|
|
||
| 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 window with the question and a place to input answer is opening. | ||
| What is the return value of `prompt`? | ||
| The input value will be returned by prompt() and stored in the variable myName. | ||
|
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 if the user entered a value and clicked the "Cancel" button (instead of the "OK" button)?
Author
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. The return value will be null for myName. meaning that no input.
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 do you mean by "no input"?
Author
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. The return will be null
Author
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. null means no value entered.
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.
Have you verified that
Author
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. Thanks for pointing that out. If cancel be clicked, the output will be null. If no value entered and OK be clicked the output will be nothing as ``. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,22 @@ | ||
| ## Objects | ||
|
|
||
| In this activity, we'll explore some additional concepts that you'll encounter in more depth later on in the course. | ||
| //In this activity, we'll explore some additional concepts that you'll encounter in more depth later on in the course. | ||
|
|
||
| Open the Chrome devtools Console, type in `console.log` and then hit enter | ||
| //Open the Chrome devtools Console, type in `console.log` and then hit enter | ||
|
|
||
| What output do you get? | ||
| // What output do you get? | ||
| // ƒ (){for(var o=arguments.length,u=new Array(o),l=0;l<o;l++)u[l]=arguments[l];if(e.apply(n,u),!("assert"===r&&u[0]||a)){a=!0;try{var | ||
| // d=Di.parse(new Error).map((t=>t.toString())).splice(1),c=("assert"===… | ||
|
|
||
| Now enter just `console` in the Console, what output do you get back? | ||
| //Now enter just `console` in the Console, what output do you get back? | ||
| // console {debug: ƒ, error: ƒ, info: ƒ, log: ƒ, warn: ƒ, …} | ||
|
|
||
| Try also entering `typeof console` | ||
| //Try also entering `typeof console` | ||
| //Answer the following questions: | ||
| //What does `console` store? | ||
| //The console in JavaScript doesn’t store the program’s variables or data — instead, it’s an object provided by the browser (or Node.js) that contains a set of methods for | ||
| //logging information, debugging, and interacting with the JavaScript environment. | ||
|
|
||
| Answer the following questions: | ||
|
|
||
| What does `console` store? | ||
| What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? | ||
| //What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? | ||
| //In both cases, console is an object, and log or assert are properties (specifically, methods) of that object. The dot (.) is called the dot notation operator or member | ||
| //access operator. It is used in JavaScript (and many other languages) to access a property or method that belongs to an object. |
Uh oh!
There was an error while loading. Please reload this page.