-
-
Notifications
You must be signed in to change notification settings - Fork 95
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
West Midlands|Azar Alampanah| Module-structuring-and-testing-data|week1 #56
base: main
Are you sure you want to change the base?
West Midlands|Azar Alampanah| Module-structuring-and-testing-data|week1 #56
Conversation
Hi @azaralampanah2, can you please take a look at the |
// Create a variable called roundedNum and assign to it an expression that evaluates to 57 ( num rounded to the nearest whole number ) | ||
|
||
// Log your variables to the console to check your answers | ||
const num = 56.5678; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good attempt 😄 But I think we can review a few concepts here.
Let's pay special attention to the requirements of the exercise: they say "Create a variable called decimalPart", but are we satisfying this requirement here? 🤔 Take a look at other examples of "creating a variable" in the prep work: https://programming.codeyourfuture.io/structuring-data/sprints/1/prep/#variables
// You should look up Math functions for this exercise https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math | ||
|
||
// Create a variable called wholeNumberPart and assign to it an expression that evaluates to 56 ( the whole number part of num ) | ||
const wholeNumberPart=console.log(`the whole part of number${num} is : ${Math.trunc(num)}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, you are declaring a variable called wholeNumberPart
and assigning it the value returned by the call to the console.log
function.
- What do you think the value of
wholeNumberPart
will be after this line? Can you output the value to find out? - What happens if you remove this line? How does it affect the rest of the code? 🤔
Can you try the above, running your code after each change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dear @moneyinthesky ,
- I tried to execute this line with different numbers. This line will return the whole part of the number without rounding the number. I reckon it is doing well, but you mean it doesn't. I would appreciate it if you could give me a clue to resolve the issue.
- I've used two different methods to show the whole part of a number and have divided them with "//or" at line 7, so if I remove this line nothing will happen, as lines 8-13 will have the same functionality and also the same output.
Thank you so much again for your precious reviews.
Sprint-1/exercises/initials.js
Outdated
// 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. | ||
|
||
let initial=firstName[0]+middleName[0]+lastName[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work here 😄
How many initials do we have here? It looks like 3, right? But if I look at the variable name initial
- it makes me think that there is only 1 initial. How can we change this to make it clear that there is more than one initial?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right!
So I changed it to "initials"! Now makes sense!
Thanks.
const base = filePath.slice(lastSlashIndex + 1); | ||
console.log(`The base part of ${filePath} is ${base}`); | ||
|
||
// Create a variable to store the dir part of the filePath variable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When writing code, it's important to think about other software developers who might be reading our code in the future. One way to make our code more readable is to use camel-case variable names. You can read more about what this means here: https://developer.mozilla.org/en-US/docs/Glossary/Camel_case
Can you try changing your variable names to camel case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dear @moneyinthesky ,
I have amended variable names to camel_case format.
Thanks
Sprint-1/exercises/paths.js
Outdated
const dirpart=filePath.slice(0,lastSlashIndex); | ||
console.log(`the dir part of ${filePath} is : ${dirpart}`); | ||
// Create a variable to store the ext part of the variable | ||
const lastdotindex=filePath.lastIndexOf("."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The exercise is asking us to store the "ext" part of the filePath
variable. Are we really storing the "ext" part here? What do you see when you run the code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry @moneyinthesky ,
I misunderstood. Now it's been amended to show "ext" part of the filePath.
Thanks.
//then multiples it by (maximum-minimum+1) | ||
//function Math.floor() gives the nearest integer of the previous line | ||
//num equals the addition of the nearest integer and minimum | ||
//so num is a random integer between minimum and maximum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice explanation 🎉
|
||
console.log(`The percentage change is ${percentageChange}`); | ||
|
||
// Read the code and then answer the questions below |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect!
//it retains the movielenght in the format of hour:minutes:seconds | ||
//we can use some other names insted of result, such as "movieduration" | ||
|
||
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the movie length is very small, for example: const movieLength = 33;
?
What will the output be? Can it be improved in any way? And if so, can you think about how to improve it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dear @moneyinthesky ,
It seems codes are working well for all non-negative, negative, and zero numbers.
|
…cisees/initials.js
Learners, PR Template
Self checklist
Changelist
Briefly explain your PR:
This PR is about my works on Module structuring and testing data/sprint1/backlog/complete sprint1 exercises
Questions
I have asked a question on sprint1/interprete/to-pounds.js and would be grateful if my question to be answered