-
-
Notifications
You must be signed in to change notification settings - Fork 221
London | Phone_Naing |Module-structuring-and-testing-data/ sprint 3 #180
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
Changes from 11 commits
bd7dae1
291b2cd
ee8c6f7
85c1a02
e3a68ad
3752b21
cc657c4
f45a428
a4edfb1
1d1b15c
dd1643e
0093253
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,7 +1,8 @@ | ||
// Predict and explain first... | ||
|
||
// Predict 320 | ||
//undefined because multiply function has to get return | ||
function multiply(a, b) { | ||
console.log(a * b); | ||
return a * b; | ||
} | ||
|
||
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
// Predict and explain first... | ||
|
||
// Predict error because a+b is another line(undefined) | ||
function sum(a, b) { | ||
return; | ||
a + b; | ||
// return; | ||
return a + b; | ||
} | ||
|
||
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
// Predict and explain first... | ||
//predict i think the error is on the Parameter for capitalise is undefined | ||
//read is str has already been declared so that mean function parameter can not replace | ||
|
||
// call the function capitalise with a string input | ||
// interpret the error message and figure out why an error is occurring | ||
|
||
//remove the redeclare variable | ||
function capitalise(str) { | ||
let str = `${str[0].toUpperCase()}${str.slice(1)}`; | ||
str = `${str[0].toUpperCase()}${str.slice(1)}`; | ||
return str; | ||
} | ||
|
||
console.log(capitalise("mgphone")); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
// Predict and explain first... | ||
//error because decimalNumber is redeclare and wrong calling function | ||
|
||
// Why will an error occur when this program runs? | ||
// Try playing computer with the example to work out what is going on | ||
|
||
// i did call the convertToPercentage with parameter | ||
function convertToPercentage(decimalNumber) { | ||
const decimalNumber = 0.5; | ||
// decimalNumber = 0.5; | ||
const percentage = `${decimalNumber * 100}%`; | ||
|
||
return percentage; | ||
} | ||
|
||
console.log(decimalNumber); | ||
console.log(convertToPercentage(0.5)); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
|
||
// Predict and explain first... | ||
//error because there is function is unfinished, calling is wrong | ||
|
||
// this function should square any number but instead we're going to get an error | ||
|
||
function square(3) { | ||
return num * num; | ||
function square(num) { | ||
return num * num; | ||
} | ||
|
||
|
||
console.log(square(3)); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,3 +33,9 @@ | |
// Then it should return true because the input forms a valid triangle. | ||
|
||
// This specification outlines the behavior of the isValidTriangle function for different input scenarios, ensuring it properly checks for invalid side lengths and whether they form a valid triangle according to the Triangle Inequality Theorem. | ||
function isValidTriangle(a, b, c) { | ||
return a + b > c && b + c > a && a + c > b; | ||
} | ||
console.log(isValidTriangle(0, 2, 1)); | ||
|
||
module.exports = isValidTriangle; | ||
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 code does not check if any of the sides are less than or equal to zero. 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. Please guide me, when i check jest all are correct... test("Invalid Triangle with Negative", () => { test("Invalid checking triangle with zero sides", () => { 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. return a + b > c && b + c > a && a + c > b; 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. @MonaZaresh In other programming languages that support integer types, if a, b, c are integer types, then we would need to check if a, b, c are all positives in addition to checking 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. Thanks, that mean my code for javascript is correct right :) |
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 do you decide to treat "02❤️", "002❤️", and "0x02❤️" the same as "2❤️", but does treat "010❤️" the same as "10❤️"?
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.
yeah i did check and all have got same value :)