Skip to content

Conversation

@Alireza1620
Copy link

No description provided.

@Alireza1620 Alireza1620 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 18, 2024
Copy link
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

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

I have left my comment in the code.

Why not try also

  • Explain and fix the errors in the files in folder errors?
  • Interpret code in the files in folder interpret
  • Answer questions in the file in folder explore

// Create a variable called decimalPart and assign to it an expression that evaluates to 0.5678 ( the decimal part of num )
// Create a variable called roundedNum and assign to it an expression that evaluates to 57 ( num rounded to the nearest whole number )
wholeNumberPart = Math.floor(num); // Create a variable called wholeNumberPart and assign to it an expression that evaluates to 56 ( the whole number part of num )
decimalPart = +(num % 1).toFixed(10);// Create a variable called decimalPart and assign to it an expression that evaluates to 0.5678 ( the decimal part of num )
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the use of the prefix +? Is it necessary?

Copy link
Author

Choose a reason for hiding this comment

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

If you look at line 6, the ".tofix(10)" will get the number, separates the decimal part and return it. But the returned decimal is now a float, it is an String. The "+" used as prefix will make sure that when the result is going to be assigned to "decimalPart" variable, is actually a number not string.
In our case it is not necessary since we only need the decimal part to be returned but if we had another operation to do on variable, it is important for mathematical part to be a number not string.

let middleName = "Katherine";
let lastName = "Johnson";

initials = [firstName[0], middleName[0], lastName[0]];
Copy link
Contributor

Choose a reason for hiding this comment

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

This would create an array ["C", "K", "J"] instead of producing a string "CKJ".

Copy link
Author

Choose a reason for hiding this comment

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

I am sure in my final code when I tested it, it retuerned CKJ. there is a chance I forgot to actually push the last line commit which will print the "initials" members together.

@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
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.

3 participants