-
-
Notifications
You must be signed in to change notification settings - Fork 195
London | May-2025 | Reza Jahanimir | Coursework/sprint 2 #524
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
base: main
Are you sure you want to change the base?
London | May-2025 | Reza Jahanimir | Coursework/sprint 2 #524
Conversation
Sprint-2/1-key-errors/0.js
Outdated
|
||
function capitalise(str) { | ||
let cap_string = `${str[0].toUpperCase()}${str.slice(1)}`; | ||
return cap_string; | ||
}; |
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.
Great solution on this question, but remember that if a variable will not be reassigned after it has been declared, then it should be a const, only use let if you believe that the variable will change later on
|
||
// =============> explain this error message here | ||
// First Two Lines: Locate the file path and the specific line of code causing the error. | ||
// Following Lines: Display the type of error (SyntaxError) and its message. |
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 simple and straight forward explanation, nice job
return result; | ||
} | ||
|
||
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); |
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.
You provided the right solution here, with a simple suggestion.
The console.log
in the function is not necessary, as you will notice that the final result will print out two results, the first is just the result, and the second will be the statement in line 24
const height_squared = height * height; |
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.
Simple solutions that are simple to read are always good code, which you have done here. Just want to draw your attention to some built-in methods that JavaScript has for this same thing
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow
} else if (hours > 12) { | ||
return `${hours - 12} pm`; | ||
} else { | ||
return `${hours} am`; | ||
} |
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.
Your solution is returning 12 pm
when we expect to see 12:00 pm
, for example.
You need to take a look at the original question again and see how you can do that 🙂
} | ||
return `${time} am`; | ||
// If you input "08:00" is allowed to pass | ||
const paddedHour = hourStr.length === 2 && displayHour < 10 ? `0${displayHour}` : `${displayHour}`; |
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 in formatting the hour it is returned. I have a resource that you might want to consider should you need to do this again in the future
Learners, PR Template
Self checklist
Changelist
tried to answer the questions and tests
Questions
Ask any questions you have for your reviewer.