Uh oh!
There was an error while loading. Please reload this page.
NW6/Nohe-Tekelmariyam/J1-Modul-week-2 - #183
Conversation
| // When we call this function with the weight and height | ||
| // Then it returns their Body Mass Index to 1 decimal place | ||
| function bmiCalculation(weight, height) { | ||
| if (typeof weight === "number" && typeof height === "number") { |
There was a problem hiding this comment.
Great to see you starting to think about input validation 👍
| const wordJoin = wordToCapital.join("_"); | ||
| return wordJoin; | ||
| } | ||
| console.log(upperSnakeCase("nohe tekel mariyam")); |
There was a problem hiding this comment.
This solution gets you to the right answer, but there are a few inefficiencies.
- This code splits the input into its component words, and then loops through the words individually to convert them to upper case. Could you instead convert to upper case at a different point to eliminate the 'map' altogether?
- The steps here are split by space character and then join with underscore. How might you instead replaceAll the spaces with an underscore instead? What might be the benefit or downside of doing it that way?
| // Come up with a clear, simple name for the function | ||
| // Use the string documentation to help you plan your solution | ||
| let string = ""; |
There was a problem hiding this comment.
What is the purpose of this line? Where is this variable used?
| // Take this code and turn it into a reusable block of code. | ||
| // Declare a function called toPounds with an appropriately named parameter. | ||
| // Call this function a number of times to check it works for different inputs | ||
| function toPounds(penceString) { |
| } | ||
| } | ||
| var price = 399; | ||
| console.log(productCostWithVat(price)); |
| / //funtion pad(num) | ||
| //{ | ||
| // return num.toString().padstart(2,"0"); | ||
| //} No newline at end of file |
| // b) What value is assigned to the parameter num when pad is called for the first time? | ||
| //remainingHours or 00 |
There was a problem hiding this comment.
00 would be the returned value of the method as you've correctly identified below. What value will be assigned to the parameter when the function is called?
varuna-v
commented
Dec 9, 2023
Hi Nohe. Good work on the implement and interpret sections - you're demonstrating a clear grasp of these Javascript fundamentals 👏 |
Learners, PR Template
Self checklist
Changelist
Briefly explain your PR.
Questions
Ask any questions you have for your reviewer.