Skip to content

London | 26-ITP-May | Hugh Mills | Sprint 1 | Sprint 1 Coursework#1450

Open
HM-127BTY wants to merge 12 commits into
CodeYourFuture:mainfrom
HM-127BTY:coursework/sprint-1
Open

London | 26-ITP-May | Hugh Mills | Sprint 1 | Sprint 1 Coursework#1450
HM-127BTY wants to merge 12 commits into
CodeYourFuture:mainfrom
HM-127BTY:coursework/sprint-1

Conversation

@HM-127BTY

Copy link
Copy Markdown

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

Completed the tasks for Complete Sprint 1 Coursework:
1-key-exercises
2-mandatory-errors
3-mandatory-interpret

@HM-127BTY HM-127BTY added 📅 Sprint 1 Assigned during Sprint 1 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Jul 3, 2026
@Gopi-2001 Gopi-2001 self-assigned this Jul 4, 2026
@Gopi-2001 Gopi-2001 added the Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. label Jul 4, 2026
Comment thread Sprint-1/2-mandatory-errors/0.js Outdated
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? No newline at end of file
//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? No newline at end of file

@Gopi-2001 Gopi-2001 Jul 6, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

For Reference, to comment multiple lines we can use multi-line comment as below

/*
This is a multi-line comment.

You can comment multiple lines at once.
*/

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Ok ill do that change to all my messages then.
What would the better use of the placement be then?

/*
like this?
*/~

/* or like this? */

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

/*
This approach provide better readability.
*/

Comment thread Sprint-1/2-mandatory-errors/3.js Outdated
// 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
// I firsth thought the -4 would not work as it starts on 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

For 0-based index, one can get the length of cardNumber and then take the last 4 digit.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

so for it to work it needs to be:
nst last4Digits = cardNumber.slice(cardNumber.length -4)
So in order to get the last 4 using just -4 wont work, need to add the .length function to cardNumber.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

with .slice() function both the approach works

Approach 1 - to get the last 4 digit, just use cardNumber.slice(-4)

Approach 2 - to get the last 4 digit, just use cardNumber.slice(cardNumber.length - 4)

@Gopi-2001 Gopi-2001 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Also try working on Module-Structuring-and-Testing-Data\Sprint-1\4-stretch-explore.
Thank you

@@ -1,9 +1,12 @@
const cardNumber = 4533787178994213;
const cardNumber = "4533787178994213";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is correct but can you think of a way to convert a number to string using some js functions and use that to get the last 4 digit.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

.toString wold work best I belive:
const cardNumber = 45334533787178994213;
let cardString = cardNumber.toString();
return last4Digits = cardString.length -4

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Here the last line would be like this :

cardString.slice(cardString.length-4)

// 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

// From what I can work out, it is generations a random number between 2 and 100 for the value of num.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Math.random() generates random number [0,1) i.e from 0 (including) to 1 (excluding).

Now can you think what will be the value of num, when random number generated is zero.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

from 0 to 1, mostly through decimals

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Think like this

Math.random() generates value in the range [0,1) where 0 is included and 1 is excluded.

Since, maximum - minimum + 1 = 100

Then Math.random()*(100) will provide value in the range [0,100) . Note thatsquare bracket [ or ]means included and normal bracket ( or ) means excluded.

Math.floor(N) - this function provide number greatest integer less than or equal to N

So for this line of code Math.floor(Math.random()*(100)), the number generate will be in the range [0,99] .

Adding minimum makes the range of variable num to [1,100] i.e. increasing the previous range by the value of 1.

console.log(`I was born in ${cityOfBirth}`);
const cityOfBirth = "Bolton";
console.log(`I was born in ${cityOfBirth}`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

what do you think, why it was not working before ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Ah the order of them in line of code was wrong, const needs to be before the console.log.

// Line 1 is a variable declaration, creating the count variable with an initial value of 0
// Describe what line 3 is doing, in particular focus on what = is doing

// Line 3 is taking the value of count, then adding 1 to that value, then making that new value to be the current count.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Apart from count = count + 1, can you look for more compact operation to increment variable by 1.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

could it be:
Let count = 0+1;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No the are other approaches, when the requirement is to increase/decrease the value of a number only by 1.

You can go through this - increase-or-decrease-a-number-by-one


// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?

// a) There are 5 calls made:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Yes there are 5 function calls, but you mentioned line 4 and 5 has a total of 4 functions call.
Can you try looking for another one.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

ah yes:
onsole.log(The percentage change is ${percentageChange});

// a) There are 5 calls made:
// carPrice = Number(carPrice.replaceAll(",", ""));
// priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," ""))
// b) Error on line 5 for "," it is missing the seperating , between "," and "".

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Instead of mentioning like that, keep it little for explicit which will easier to pin point the error.
Like - "For function call priceAfterOneYear.replaceAll("," "") comma is missing between the arguments "

Can you look what the term arguments means in Programming language ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thats an object that is only available inside a function.
So for example its "The percentage change is" and ${percentageChange}" would be arguments here :
console.log(The percentage change is ${percentageChange});

// a) There are 6: movieLength, remainingSeconds, totalMinutes, remainingMinutes, totalHours, result.
// b) There is one: console.log.
// c) It is taking the movieLength and doing a remainder that is showing what is left after the vaule has been divided, in this case wil be 84.
// I found the info here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Remainder

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Note Remainder = Dividend % Divisor , and the rule is remainder always strictly less than divisor.
For movieLength % 60, can you re-evalute what the remainder will be ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

it would be "8784 % 60 = 24"
My math was wrong there. (I think I tried to do it would a calculator)

// I found the info here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Remainder
// d) It is removing any extra seconds from the division by 60 so that is is showing as whole numbers without decimals.
// e) Result is showing the movies duration but broken down to hours:minutes:seconds, I think it should be movieDuration to help describe it better.
// f) Yes, it does work to show the lenght even if it is only in one section, though it does show values of 0, could clean it up to show nothing. No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

movieLength is a Number and apart from 0 what all different number do you think will provide incorrect response. Think of different Types of Number we have in Number system.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Negative numbers or decimal numbers?

@Gopi-2001 Gopi-2001 added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Jul 7, 2026
@HM-127BTY HM-127BTY added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Reviewed Volunteer to add when completing a review with trainee action still to take. 📅 Sprint 1 Assigned during Sprint 1 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants