Skip to content

Comments

London | ITP-JAN-2026 | Said Fayaz Sadat | Sprint 1 | coursework/sprint 1#997

Open
fayaz551 wants to merge 4 commits intoCodeYourFuture:mainfrom
fayaz551:coursework/Sprint-1
Open

London | ITP-JAN-2026 | Said Fayaz Sadat | Sprint 1 | coursework/sprint 1#997
fayaz551 wants to merge 4 commits intoCodeYourFuture:mainfrom
fayaz551:coursework/Sprint-1

Conversation

@fayaz551
Copy link

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

i have completed all 4 exercises of sprint 1 with explanation and working code as well.

Questions

n/a

@fayaz551 fayaz551 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Feb 19, 2026
@Theoreoluwa Theoreoluwa added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Feb 25, 2026
Comment on lines +14 to +18
// Math.random() generates a random decimal number between 0 (inclusive) and 1 (exclusive). So it can be any value from 0 up to but not including 1.
// (maximum - minimum + 1) calculates the range of possible values, which is 100 - 1 + 1 = 100. This means we want to generate a random number between 0 and 99 (inclusive) before adding the minimum value.
// Math.random() * (maximum - minimum + 1) gives us a random decimal number between 0 (inclusive) and 100 (exclusive). This means it can be any value from 0 up to but not including 100.
// Math.floor() takes the random decimal number and rounds it down to the nearest whole number. This means we will get an integer value between 0 and 99 (inclusive).
// Finally, we add the minimum value (1) to the result, which shifts the range from 0-99 to 1-100. So num will be a random integer between 1 and 100 (inclusive). No newline at end of file

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great description.

Comment on lines +15 to +17
const cardNumber = 4533787178994213;
const last4Digits = cardNumber.toString().slice(-4);
console.log(last4Digits); No newline at end of file

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good way to go about the solution without redeclaring the variable

//
// The code above won't work because the variable names suggest that twelveHourClockTime should represent a time in 12-hour format, while twentyFourHourClockTime should represent a time in 24-hour format. However, the values assigned to these variables are not consistent with their names. To fix this error, we can either change the variable names to match the values or update the values to match the variable names. For example:

const twelveHourClockTime = "08:53 PM";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good observation to both variable name and time format

Comment on lines 14 to +19
// a) How many function calls are there in this file? Write down all the lines where a function call is made
// There are 4 function calls in this file. The lines where a function call is made are:
// Line 1: carPrice.replaceAll(",", "")
// Line 2: priceAfterOneYear.replaceAll(",", "")
// Line 3: Number(carPrice.replaceAll(",", ""))
// Line 4: Number(priceAfterOneYear.replaceAll(",", ""))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you have a look again and see if you would notice a different number of function calls within the code block?

// Line 4: Number(priceAfterOneYear.replaceAll(",", ""))

// b) Run the code and identify the line where the error is coming from - why is this error occurring? How can you fix this problem?
// The error is occurring on 4 where we are trying to convert the string values of carPrice and priceAfterOneYear to numbers using the Number function. The error is occurring because the replaceAll method is being called on a string that has not been updated with the new value after the first replaceAll call. To fix this problem, we can update the carPrice and priceAfterOneYear variables with the new values after the replaceAll calls. For example:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have a look at the code in the task again and re-evaluate the answer to the question.


// The variable result represents the formatted string that shows the length of the movie in hours, minutes, and seconds. A better name for this variable could be formattedMovieLength or movieDurationFormatted, as it more clearly indicates that it is a formatted representation of the movie length.
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
// This code will work for all non-negative integer values of movieLength, as it is designed to convert a length in seconds into a format of hours, minutes, and seconds. However, if movieLength is a negative value, the calculations may not make sense in the context of a movie length, and the output may not be meaningful. No newline at end of file

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also think of any scenario where some positive integer values may not produce a good output when applied?

Comment on lines 5 to +15
Open the Chrome devtools Console, type in `console.log` and then hit enter

What output do you get?
function defination


Now enter just `console` in the Console, what output do you get back?
This prints the entire console object with all its methods, like log, warn, error, etc.

Try also entering `typeof console`
This prints the entire console object with all its methods, like log, warn, error, etc.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let your comment contain the actual output gotten from running the operation in the task.

Comment on lines +22 to +24
console.log("Hello") calls the log method to print something to the console.

console.assert(condition, "Message") calls the assert method to check a condition, and only prints the message if the condition is false.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to answer the questions according to the task requirement. Go through the question again and give a more direct answer.

Copy link

@Theoreoluwa Theoreoluwa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very well done, Said. Please take a look at the comments attached to make it better.

@Theoreoluwa Theoreoluwa added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants