Skip to content
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

NW6 | Rabia Avci | JS1 Module | [TECH ED] Complete week 1 exercises | Week1 #130

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

RbAvci
Copy link

@RbAvci RbAvci commented Nov 10, 2023

Self checklist

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

Changelist

Ive tried to solve JS1-week 1 exercises. They were a bit hard to understand. I tried to break down each line to make it easier to understand.

Questions

padStart and padEnd are not very clear yet in my mind.

Copy link

@Ara225 Ara225 left a comment

Choose a reason for hiding this comment

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

This is mostly really good but there are a few mistakes. If you can, please reveiw my comments and make sure you understand why you slipped up. Need to get the foundations right!


// answer
// we turned it comment with // for human consumption
Copy link

Choose a reason for hiding this comment

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

👍

// const age = 33;
// age = age + 1;

let age = 33;
Copy link

Choose a reason for hiding this comment

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

👍

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

// By declaring cityOfBirth before using it in the template string, we can be able to print the string "I was born in Bolton" without any issues.
Copy link

Choose a reason for hiding this comment

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

Very good and well explained

// The last4Digits variable should store the last 4 digits of cardNumber
// However, the code isn't working
// Make and explain a prediction about why the code won't work
// Then try updating the expression last4Digits is assigned to, in order to get the correct value

// answer
// The slice method is used on strings, not numbers. with "" made string then slice function worked
Copy link

Choose a reason for hiding this comment

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

Very well said!


const twelve_HourClockTime = "20:53";
const twentyFour_hourClockTime = "08:53";
Copy link

Choose a reason for hiding this comment

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

👍

// c) Using documentation on MDN, explain what the expression movieLength % 60 represents

// * movieLength % 60 represents the remaining seconds after dividing movieLenght by 60 (seconds)
Copy link

Choose a reason for hiding this comment

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

Makes sense :)

// d) Interpret line 4, what does the expression assigned to totalMinutes mean?

//*const totalMinutes = (movieLength - remainingSeconds) / 60; It calculates total minutes by dividing movieLength - remainingSeconds by 60
Copy link

Choose a reason for hiding this comment

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

👍

// e) What do you think the variable result represents? Can you think of a better name for this variable?

//* formattedMovieLength
Copy link

Choose a reason for hiding this comment

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

Nice name

// f) Think about whether this program will work for all values of movieLength.
// Think of what values may cause problems for the code.
// Decide the result should be for those values, then test it out.
// Can you find any values of movieLength which don't give you what you'd expect?

//*This program will work for all positive integer values of movieLength. However, it may not handle negative values. Like movieLength = -8784
// for negative values we can add a conditional check and take the absolute value.
Copy link

Choose a reason for hiding this comment

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

Makes sense However, taking the absolute value of the var might cause confusion. Normally, you'd either throw an exception or return an empty value. It's important to be predicatable where possible or at least clearly document that the function behaves in an odd way and why

// Line 14 Extracts the pounds part from paddedPenceNumberString by taking characters from the beginning up to the length of paddedPenceNumberString - 2.
// Line 21 Extracts the last two characters (representing pence) from paddedPenceNumberString and then pads the result with trailing zeros using padEnd to ensure it has two characters.

// Line 25 Prints the final formatted string by combining pounds, a dot, and pence, with a pound sign (£) at the beginning.
Copy link

Choose a reason for hiding this comment

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

Makes sense!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants