-
-
Notifications
You must be signed in to change notification settings - Fork 195
Module-Structuring-and-Testing-Data sprint2 Nurzat Nurdinova #622
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
// Predict and explain first... | ||
// =============> write your prediction here | ||
|
||
// The code will throw an error because the variable `str` is being declared twice in the same scope. | ||
|
||
// call the function capitalise with a string input | ||
// interpret the error message and figure out why an error is occurring | ||
|
||
|
||
function capitalise(str) { | ||
let str = `${str[0].toUpperCase()}${str.slice(1)}`; | ||
return str; | ||
} | ||
capitalise("hello,this is a test"); | ||
|
||
// | ||
|
||
// =============> write your explanation here | ||
// =============> write your new code here | ||
//// The error occurs because the variable `str`is declared twice in the same scope,which is not allowed in JavaScript. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
// Predict and explain first... | ||
// =============> write your prediction here | ||
|
||
// The code will not return the sum of the two numbers because the return statement is placed before the actual addition operation. | ||
function sum(a, b) { | ||
return; | ||
a + b; | ||
return a + b; | ||
|
||
|
||
} | ||
|
||
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); | ||
|
||
// =============> write your explanation here | ||
// | ||
// Finally, correct the code to fix the problem | ||
// =============> write your new code here | ||
// |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,7 @@ | |
// You will need to come up with an appropriate name for the function | ||
// Use the MDN string documentation to help you find a solution | ||
// This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase | ||
function upperSnakeCase(str) { | ||
return (upperSnakeCase = str.replaceAll(" ", "_").toUpperCase()); | ||
} | ||
console.log(upperSnakeCase("Congratulations having a boy! 🎉")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a bug at line 18. If you call |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,9 @@ | |
// 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(kg) { | ||
const pounds =kg *2.20462; | ||
return pounds.toFixed(2); | ||
|
||
} | ||
Comment on lines
+7
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The objective is to turn the code in |
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 the function to return? A number or a string?
Does your function return the type of value you expect it to return?
There is a syntax error at line 20.
Did you forget to declare
squareHeight
andbmi
?