-
-
Notifications
You must be signed in to change notification settings - Fork 240
Glasgow | 25-ITP-Sep | Abraham-Habte | Sprint 2 | Coursework/sprint-2 #809
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?
Conversation
|
Your PR description contained template fields which weren't filled in. Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
|
Your PR description contained template fields which weren't filled in. Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
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.
A clean branch should not contain any unrelated change.
Change = difference between your branch and the target branch (CYF's main).
When you delete files originally in the repo (e.g., files in Sprint-1 folder), they will be identified as changed files.
To keep this branch clean, can you restore the files in the Sprint-1 folder (by copying the same files from CYF's main)?
- Download the repo as a ZIP file and unzip the file to a temporary folder.
- On your local repository, switch to
coursework/sprint-2branch. - Replace the
Sprint-1folder in your repo by theSprint-1folder in the temporary folder - Commit the change and push the change to GitHub.
| return str; | ||
| } | ||
| // The error occurs in line 13 and it says "SyntaxError: Identifier 'str' has already been declared" | ||
| // The error is informing us that the string str has already been declared in line 12 so we can not declare it again. |
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 string str
Calling str a "string" isn’t quite right. Try using a term that describes it as a name rather than a value.
Accurate terminology is essential for clear communication and precise reasoning about how code works.
| function calculateBMI(weight, height) { | ||
| function calculateBMI(weight, height) { | ||
| const bmi= weight/ (height*height) | ||
| return bmi.toFixed(1); |
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 type of value do you expect your function to return? A number or a string?
Does your function return the type of value you expect?
Different types of values may appear identical in the console output, but they are represented and treated differently in the program. For example,
console.log(123); // Output 123
console.log("123"); // Output 123
// Treated differently in the program
let sum1 = 123 + 100; // Evaluate to 223 -- a number
let sum 2 = "123" + 100; // Evaluate to "123100" -- a string.| } | ||
|
|
||
| console.log(toUpperCase("hello there")); | ||
| console.log(toUpperCase("lord of the ring")); |
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.
Does this output LORD_OF_THE_RINGS?
| // You will need to declare a function called toPounds with an appropriately named parameter. | ||
|
|
||
| // You should call this function a number of times to check it works for different inputs | ||
| function toPounds(pennies) { |
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 parameter value is expected to be a string in the form "399p" (a sting with a trailing 'p').
|
|
||
| // d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer | ||
| // =============> write your answer here | ||
| /* The value assigned to num when the pad is called for the last time is "1". */ |
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.
A notation like "1" (a value enclosed by a pair of double quotes) is conventionally used to suggest the value is a string.
So use of double quotes on "00" in the previous question is good. But for a number-type value, use of double quotes could be misleading.
| function formatAs12HourClock(time) { | ||
| const hours = Number(time.slice(0, 2)); | ||
| if (hours===0) { | ||
| return`12:00 am` | ||
| } | ||
| if (hours===12) { | ||
| return `12:00 pm` | ||
| } | ||
| if (hours > 12) { | ||
| return `${hours - 12}:00 pm`; | ||
| } | ||
| return `${time} am`; | ||
| if (hours > 0 && hours < 12) | ||
| return `${String(hours).padStart(2, "0")}:00 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.
Does your function return the value you expected from each of the following function calls?
formatAs12HourClock("00:31")formatAs12HourClock("12:31")formatAs12HourClock("01:31")formatAs12HourClock("13:31")
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.
Some of the scripts you changed has some issues. Can you test all your scripts to ensure the code in the scripts works as expected?
| } | ||
|
|
||
| console.log(toUpperCase("hello there")); | ||
| console.log(toUpperCase("lord of the ring")); |
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.
Does your function work for this function call? Does it output LORD_OF_THE_RING?
console.log(toUpperCase("lord of the ring"));
| return `${String(hours).padStart(2, "0")}:00 am`; | ||
| const minutes = time.slice(3, 5); | ||
| const ampm = hours >= 12 ? "pm" : "am"; | ||
| const Hour = String(hours % 12 === 0 ? 12 : hours % 12).padStart(2, "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.
The convention is to begin a variable name with a lowercase letter.
Name that begins with an uppercase letter is conventionally reserved for data type. For example, String.
| } | ||
| if (hours > 0 && hours < 12) | ||
| return `${String(hours).padStart(2, "0")}:00 am`; | ||
| const minutes = time.slice(3, 5); |
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.
time.slice(-2) is probably more expressive (no need to calculate the starting and ending positions).
| function capitalise(firstLetters) { | ||
| firstLetters = `${firstLetters[0].toUpperCase()}${firstLetters.slice(1)}`; | ||
| return firstLetters; |
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.
Why changed str to firstLetters?
Learners, PR Template
Self checklist
Changelist
I have done all the tasks required for this sprint
Questions
No questions