Sheffield | ITP-Jan-26 | Hayriye Saricicek | Sprint 1 | Structuring and Testing Data#1126
Sheffield | ITP-Jan-26 | Hayriye Saricicek | Sprint 1 | Structuring and Testing Data#1126mshayriyesaricicek wants to merge 16 commits intoCodeYourFuture:mainfrom
Conversation
| const dir = ; | ||
| const ext = ; | ||
| const dir =filePath.slice(0, lastSlashIndex) | ||
| const ext =base.slice(base.lastIndexOf(".") + 1) |
There was a problem hiding this comment.
Code is correct.
Have you followed the suggestion in https://github.com/mshayriyesaricicek/Module-Structuring-and-Testing-Data/blob/main/readme.md to enable "Format on Save/Paste" on your VSCode? Doing so can help keep your JS code formatted consistently. For examples, it would
- Ensure one space between each operator
- Terminate each statements by a semicolon
This is the result of auto-format.
const dir = filePath.slice(0, lastSlashIndex);
const ext = base.slice(base.lastIndexOf(".") + 1);
There was a problem hiding this comment.
Thank you. Format on Save was not switched on so I have switched it on now.
|
|
||
| //num is a random number between 1 and 100 | ||
| //Math.floor rounds the decimal number to nearest lower number | ||
| // Math.random() generates a random decimal number between 0 and 1 |
There was a problem hiding this comment.
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.
We can also use the concise and precise interval notation to describe a range of values.
[,]=> inclusion(,)=> exclusion
For example, [1, 10) means, all numbers between 1 and 10, including 1 but excluding 10.
There was a problem hiding this comment.
Thank you. I have changed this now.
Sprint-1/2-mandatory-errors/3.js
Outdated
| function last4Digits(cardNumber) | ||
| return `${cardNumber}`.slice(-4); |
There was a problem hiding this comment.
The syntax of this function definition is not quite correct.
Sprint-1/2-mandatory-errors/4.js
Outdated
| const 24hourClockTime = "08:53"; No newline at end of file | ||
| const 24hourClockTime = "08:53"; | ||
| // variable names cannot begin with a number | ||
| // can change to ClockTime12Hour and ClockTime24Hour or something similar to make it valid No newline at end of file |
There was a problem hiding this comment.
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., Math)
Sprint-1/4-stretch-explore/chrome.md
Outdated
| What is the return value of `prompt`? | ||
| when I do console.log(answer); it returns the value myName |
There was a problem hiding this comment.
If we were writing a program that uses prompt() to ask for an input value, how could
the program find out if the user clicked "OK" or "Cancel"?
There was a problem hiding this comment.
Using console.log shows whether the user has clicked Ok or Cancel or typed their name. I have ameded my answers to show this.
|
|
||
| console.assert tests for a condition but only returns a message if the condition is false. For instance it may be used to check the age of a person to restrict access to a site for adults only. | ||
|
|
||
| the full stop is used to separate the object from the method. Console is the object and log and assert are methods No newline at end of file |
There was a problem hiding this comment.
. is an operator. Can you also find out the name of this operator and what it does in general?
There was a problem hiding this comment.
I have added more comments to explain the dot operator.
Self checklist
Changelist
I am completing the exercises on Sprint 1. I am making commits as I continue.