-
-
Notifications
You must be signed in to change notification settings - Fork 382
London | 26 ITP May | Sayeed Hussain | Sprint 1 | Coursework #1368
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
dc592e4
8e4be20
5410ef4
c4d5c88
5c345ec
628bf03
07c3a74
1cca8c8
220c59b
3b6570f
e9597fb
ca85fbb
8977800
6a11e8e
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 |
|---|---|---|
|
|
@@ -7,5 +7,8 @@ let lastName = "Johnson"; | |
|
|
||
| let initials = ``; | ||
|
|
||
| // https://www.google.com/search?q=get+first+character+of+string+mdn | ||
| let initials = `${firstName.charAt(0)} ${middleName.charAt(0)} ${lastName.charAt(0)}`; | ||
|
|
||
| console.log(initials); | ||
|
Comment on lines
+10
to
+12
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. Currently, the value assigned to |
||
|
|
||
| // https://www.google.com/search?q=get+first+character+of+string+mdn | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,12 +12,15 @@ | |
| const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file.txt"; | ||
| const lastSlashIndex = filePath.lastIndexOf("/"); | ||
| const base = filePath.slice(lastSlashIndex + 1); | ||
| console.log(`The base part of ${filePath} is ${base}`); | ||
| // 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); | ||
|
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. Do you intend to including a trailing |
||
| const ext = filePath.slice(filePath.lastIndexOf(".")); | ||
|
|
||
| // https://www.google.com/search?q=slice+mdn | ||
| // console.log(ext); | ||
|
|
||
| // https://www.google.com/search?q=slice+mdn | ||
| // console.log(dir); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,3 +7,11 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; | |
| // Try breaking down the expression and using documentation to explain what it means | ||
| // It will help to think about the order in which expressions are evaluated | ||
| // Try logging the value of num and running the program several times to build an idea of what the program is doing | ||
|
|
||
| // console.log(num); | ||
|
|
||
| // 1) Num represent a randomly generated whole number between maximum and minimum // | ||
|
|
||
| // 2) Firstly, Math.random create a random number between 0 to 1 then using a maximum and minimum,which gives us range. | ||
| // Multiplying them create a random number inside that range. Math.floor remove decimal parts and give us whole number | ||
| // finally we add minimum number ( + minimum),which start from a minimum value. Therefore num represent a whole number. | ||
|
Comment on lines
+13
to
+17
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. Phrases like "a number between X and Y" are not precise enough in a program specification, because they do not clearly state whether the endpoints X and Y are included. Could you describe the range of the numbers each of the following expressions may produce?
Note: One way to describe a range of numbers is to use the math's interval notation:
For example, |
||
| 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? | ||
| We don't want the computer to run these 2 lines - how can we solve this problem? | ||
|
|
||
| // We comment them using slash(//) where human can read and computer can't read because it is not a code or translated into code// |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| // 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); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| // 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}`); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| const cardNumber = 4533787178994213; | ||
| const last4Digits = cardNumber.slice(-4); | ||
| let cardNumber = 4533787178994213; | ||
| const ToString = cardNumber.toString(); | ||
|
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 JS naming convention, variable names usually begins with a lowercase letter. Names starting with an uppercase letter are used for built-in and custom data types (e.g., |
||
| let last4Digits = ToString.slice(-4); | ||
| console.log(last4Digits); | ||
|
|
||
| // The last4Digits variable should store the last 4 digits of cardNumber | ||
| // However, the code isn't working | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| const 12HourClockTime = "8:53pm"; | ||
| const 24hourClockTime = "20:53"; | ||
| const HourClockTime = "8:53pm"; | ||
| const hourClockTime = "20:53"; | ||
|
Comment on lines
+1
to
+2
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. Could you also rename these to match JS naming convention? |
||
| // console.log(HourClockTime); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ let carPrice = "10,000"; | |
| let priceAfterOneYear = "8,543"; | ||
|
|
||
| carPrice = Number(carPrice.replaceAll(",", "")); | ||
| priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); | ||
| priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); | ||
|
|
||
| const priceDifference = carPrice - priceAfterOneYear; | ||
| const percentageChange = (priceDifference / carPrice) * 100; | ||
|
|
@@ -20,3 +20,9 @@ console.log(`The percentage change is ${percentageChange}`); | |
| // d) Identify all the lines that are variable declarations | ||
|
|
||
| // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? | ||
|
|
||
| // 1) five function call there including log function .Lines 4 has two function and lines 5 has two function . | ||
| // 2 ) problem was line number 5 where comma was missing. | ||
|
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. We can more precisely describe "A comma is missing between What is the programming term that belongs in the blank? |
||
| // 3) reassignment statement lines are 4 and 5. | ||
| // 4) declaration lines are 1,2,7 and 8 | ||
| // 5) line number 4, first it is removing commas using replaceAll then converting string to number for calculation. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| const movieLength = 8784; // length of movie in seconds | ||
|
|
||
| // 9237, 8784, -5897... | ||
| const remainingSeconds = movieLength % 60; | ||
| const totalMinutes = (movieLength - remainingSeconds) / 60; | ||
|
|
||
|
|
@@ -23,3 +23,10 @@ console.log(result); | |
| // e) What do you think the variable result represents? Can you think of a better name for this variable? | ||
|
|
||
| // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer | ||
|
|
||
| // a) there are 6 variable declaration. | ||
| // b) there is zero function call . (only one is console.log but it is not part code execution) | ||
| // c)represents the number of seconds left over after converting the movie length into whole minutes. | ||
| // d) It calculates how many whole minutes are in the movie after taking away extra second that don't make full minutes. | ||
| // e) it represents time format like hours : minutes: second and I think MovieLengthDuration or short MovieDuration | ||
|
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. Could consider including a "formatted" prefix in the name to suggest it stores a string. |
||
| // I think all value will work except negative value because negative value gives negative outcome. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,11 @@ invoke the function `alert` with an input string of `"Hello world!"`; | |
|
|
||
| What effect does calling the `alert` function have? | ||
|
|
||
| 1. alert function display a pop-up message box in the browser containing text "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? | ||
| What is the return value of `prompt`? | ||
|
|
||
| 2. calling a prompt display a pop-up message box and ask for user input and prompt return a text entered by user as string. | ||
|
Comment on lines
20
to
+22
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 does |
||
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.
Operation like
count = count + 1is very common in programming, and there is a programming term describing such operation.Can you find out what one-word programming term describes the operation on line 3?