-
-
Notifications
You must be signed in to change notification settings - Fork 73
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
Glasgow_Class|Shreef_Ibrahim|Structuring _Testing _Datast|Week1_exercise1-update #234
base: main
Are you sure you want to change the base?
Glasgow_Class|Shreef_Ibrahim|Structuring _Testing _Datast|Week1_exercise1-update #234
Conversation
The current branch contains only one modified file. You need to copy your modified files from branch When you have updated this branch, you can add a "Need Review" label and tag me. |
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.
Code is generally good.
I left some comments and suggestions.
Sprint-1/errors/3.js
Outdated
@@ -1,9 +1,14 @@ | |||
const cardNumber = 4533787178994213; | |||
const last4Digits = cardNumber.slice(-4); | |||
const last4Digits = cardNumber.slice(4); |
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.
Have you tried executing this script to see if it works?
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.
Yes it log error => TypeError: cardNumber.slice is not a function.
I have updated the code by Convert the number to a string using .toString()
and Slice(-4) extract the last 4 characters of the string, starting from the end.
now the output of last4Digits correctly stores "4213"
Sprint-1/exercises/count.js
Outdated
@@ -1,6 +1,8 @@ | |||
let count = 0; | |||
|
|||
count = count + 1; | |||
count = count++; |
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.
Why changed the original code at line 3?
If you want to use ++
operator, you can just write count++
without the assignment operator.
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.
I have updated
Sprint-1/exercises/decimal.js
Outdated
@@ -7,3 +7,11 @@ const num = 56.5678; | |||
// Create a variable called roundedNum and assign to it an expression that evaluates to 57 ( num rounded to the nearest whole number ) | |||
|
|||
// Log your variables to the console to check your answers | |||
var wholeNumberPart = Math.floor(num); |
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.
It is better to use 'let' than 'var' to declare variable.
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.
I have updated
Sprint-1/exercises/initials.js
Outdated
@@ -4,3 +4,5 @@ let lastName = "Johnson"; | |||
|
|||
// Declare a variable called initials that stores the first character of each string. | |||
// This should produce the string "CKJ", but you must not write the characters C, K, or J in the code of your solution. | |||
var initials = | |||
firstName.slice(0, 1) + middleName.slice(0, 1) + lastName.slice(0, 1); |
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.
There is a simpler syntax to retrieve the first character from a string.
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.
Strings in JavaScript can be treated like arrays of characters, so i have updated using firstName[0] + middleName[0] + lastName[0], now i think more accrued
Sprint-1/exercises/paths.js
Outdated
@@ -16,3 +16,6 @@ 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 | |||
|
|||
var dir = filePath.slice(0, lastSlashIndex); | |||
var ext = base.slice(4); |
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 would you change your code so that it can also work for file paths like
/path1/.git/filename.js
/path1/path2/package.json
?
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.
I have updated its dynamic now.
1- /path1/.git/filename.js
2- /path1/path2/package.json
the expected output :
The base part files1 and 2 paths are filename.js , package.json
The dir part of file 1 and 2 paths are /path1/.git, /path1/path2
The ext part of file 1 and 2 paths are .js, .json
// The variable num represents a random integer between 1 and 100. | ||
// so each time you run the program, a different integer within the range [1, 100] will be generate. |
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.
To test your understanding, how would you write an expression
(without using any variable in the expression) that yields a random
integer between -5 and 3 (including -5 and 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.
Math.floor(Math.random() * (3 + 5 + 1)) - 5;
// c) Using documentation, explain what the expression movieLength % 60 represents | ||
// The remainder (%) operator returns the remainder left over when one operand is divided by a second operand. It always takes the sign of the dividend.fb |
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.
What does this particular remainder represent?
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.
Represents the remaining minutes that are not part of a full hour when the movie length is expressed in hours and minutes.
Sprint-1/interpret/time-format.js
Outdated
|
||
// e) What do you think the variable result represents? Can you think of a better name for this variable? | ||
// its using tamplat to store variable and any tex /the better name could be time |
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.
time
may also imply value like "8:45 pm" or "20:45". Can you come out with a more suitable name?
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.
i think. movieRuntime
// this will finsh i 4 steps A/initialises a string variable/B- git the value (paddedPenceNumberString.length - 2 == 1)and take us arg | ||
// C/ calc paddedPenceNumberString.substring(1)=="99" and the resultof padEnd() = 99 asign tp the pence |
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.
Can we expect this program to work as intended even if we deleted .padEnd(2, "0")
from the code?
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.
yes, it will work because it formatted when added earlier padStart(3, "0").
Learners, PR Template
Self checklist
Changelist
Briefly explain your PR.
Questions
Ask any questions you have for your reviewer.