Skip to content

LONDON | GISLAINE_DELLA_BELLA | Module-Structuring-and-Testing-Data | SPRINT 1 - #187

Closed
Della-Bella wants to merge 7 commits into
CodeYourFuture:mainfrom
Della-Bella:Sprint-1
Closed

LONDON | GISLAINE_DELLA_BELLA | Module-Structuring-and-Testing-Data | SPRINT 1#187
Della-Bella wants to merge 7 commits into
CodeYourFuture:mainfrom
Della-Bella:Sprint-1

Conversation

@Della-Bella

Copy link
Copy Markdown

Self checklist

[X ] I have committed my files one by one, on purpose, and for a reason
[ X] I have titled my PR with COHORT_NAME | FIRST_NAME LAST_NAME | REPO_NAME | WEEK
[X ] I have tested my changes
[X ] My changes follow the style guide
[X ] My changes meet the requirements of this task
Hi volunteer,

Here are my exercises from Sprint 1.

I had to ignore my first branch f and restart again as I was making my changes only in one branch and even following what CJ Juan posted on Slack I couldn't merge the last with the new. So here is going again/exercises Sprint 1.

Thank you for taking the time to review them.
Gislaine

Changelist

  • Recommit all Sprint 1 exercises and create a new PR

@SallyMcGrath SallyMcGrath added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 24, 2024

@cjyuan cjyuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I left my comments in the code.

Why not also try questions in the files in folder explore?

Comment thread Sprint-1/errors/3.js
// The code isin't work because slice is a method for strings and arrays, but cardNumber is defined as a number.
// use slice on a number will result in an error.

const cardNumber = "4533787178994213";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you were not allowed to modify the original value assigned to cardNumber (that is, keep it as 4533787178994213), How would you modify your code?

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.

// New solution without modifying the const cardNumber. I converted it to a String and then used the function Slice because Slice can only be used in a string.

Comment thread Sprint-1/errors/3.js
const cardNumber = "4533787178994213";
const last4Digits = cardNumber.slice(-4);

function cardnumber() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This function is not needed. You can just modify the following statement to assign the result to the last4Digits variable, or introduce another variable if needed.
const last4Digits = cardNumber.slice(-4);

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.

done, correct it without modify the const CardNumber

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

// on line 3 the variable is getting the value of a variable count and adding 1 to it

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There is a shorter programming term for operation like count = count + 1. You can try feeding the code to ChatGPT to see how else the code can be described. From time to time you may learn new terminology or more concise ways to describe code.

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.

This is count++;


// 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.
function initials() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could also just assign the result to a variable.

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.

Done/ New solution assigns it in variables:

let firstInitial = firstName.charAt(0);
let middleInitial = middleName.charAt(0);
let lastInitial = lastName.charAt(0);

And if the number is negative it will round it to nearest = -4.7 = -5

Match.random= is a js function that generates random numbers
between 0 and 1.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The phrase "between 0 and 1" alone is not precise enough in program specification because it does not state clearly whether 0 and 1 are included in the range.
Does the random value returned by Math.random() include 0? Does the return value include 1?
After you find out the answer, may I suggest asking ChatGPT how to precisely describe a range of numbers from 0 to 1 that include/exclude 0/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.

The num function will generate a random number between 0 and 100. Math.random() would include 0 but as we have " + minimum" this will add 1 to the result. so 0 + 1 will never be 0.

//1,2 7, 8

// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
//it transform a format number price in a number

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What kind of "transformation"? There are several things happened in this statement. May I suggest ChatGPT?

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.

This is what chat GTP gave me .. Seen more clear

carPrice.replaceAll(",", ""): This part removes all commas (",") from the carPrice string.

Number(...): This attempts to convert the resulting string (without commas) into a numerical value.

The purpose of this expression is to prepare the carPrice string for numerical calculations.

By removing the commas, it ensures that the string can be correctly interpreted as a number by the Number() function

Comment thread Sprint-1/interpret/time-format.js Outdated

// b) How many function calls are there?

//6

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Which 6 function calls are you referring to?

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.

Correct answer:
0; the code uses variables (movieLength, remainingSeconds, totalMinutes, remainingMinutes, totalHours, result) to store values.

It performs calculations using arithmetic operators like % (modulo) and / (division).

It uses string interpolation (${...}) to create the formatted output.


//6
// c) Using documentation, explain what the expression movieLength % 60 represents
//divided by 60, it's convert seconds to a time format

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This description (and also the descriptions in other comments in this file) are not precise enough. Why don't you ask your new friend ChatGPT for some suggestions.

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 is clear now. is used to show the number of remaining seconds after calculating the total number of minutes in the movie.

"The expression movieLength % 60 in JavaScript represents the modulo operation, which calculates the remainder of the division between movieLength and 60.

In simpler terms:

It divides the movieLength (in seconds) by 60 (the number of seconds in a minute).
The result of this division might have a remainder (e.g., if the movie length is not perfectly divisible by 60).
The % operator specifically extracts this remainder.
Purpose in the Code:

In the given code snippet, movieLength % 60 is used to determine the number of remaining seconds after calculating the total number of minutes in the movie. This is crucial for accurately representing the movie's duration in hours, minutes, and seconds.

Example:

If movieLength is 2784 seconds:

2784 / 60 = 46 with a remainder of 24
movieLength % 60 will result in 24, indicating that there are 24 seconds remaining after 46 full minutes.

Comment thread Sprint-1/interpret/to-pounds.js Outdated
0,
penceString.length - 1
);
0, // extracts a portion of the string here starting from index 0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems to have some typo in this comment.
Some of the other comments are not precise enough.

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.

I understand clearly now asking to chat GTP line by line.
Revised code and explanation in VS

Comment thread Sprint-1/interpret/to-pounds.js Outdated
.substring(paddedPenceNumberString.length - 2)
.padEnd(2, "0");
.substring(paddedPenceNumberString.length - 2) // extracts the last 2 characters from the strin
.padEnd(2, "0"); //ensures the string is at least 2 characters long

Copy link
Copy Markdown
Contributor

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?

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.

I asked cha Gtp and it explain me that it would work as I expected because, without .padEnd(2, "0"), the pence value would be displayed as a single digit when it's less than 10.

Ex: "399p" would be incorrectly displayed as "£3.9" instead of the correct "£3.99".

@cjyuan cjyuan 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. labels Nov 29, 2024
@Della-Bella

Copy link
Copy Markdown
Author

Hi cjyuan,
I have revised all the exercises, and they are now clearer to me than they were when I did it.
thank you

@Della-Bella Della-Bella added the Complete Volunteer to add when work is complete and all review comments have been addressed. label Jan 15, 2025
@Della-Bella

Copy link
Copy Markdown
Author

Sorry, what should I do here with this conflict?

@cjyuan

cjyuan commented Jan 16, 2025

Copy link
Copy Markdown
Contributor

Ignore the conflict, we do not need to merge.

@Della-Bella

Copy link
Copy Markdown
Author

ok thank you
have a nice day ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed. 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.

4 participants