-
-
Notifications
You must be signed in to change notification settings - Fork 50
NW6 | Nohe-Tekelmariyam | JS1-Module | Week-3 #185
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 |
---|---|---|
|
@@ -21,3 +21,18 @@ | |
// Identify Reflex Angles: | ||
// When the angle is greater than 180 degrees and less than 360 degrees, | ||
// Then the function should return "Reflex angle" | ||
function getAngleType(Angles) { | ||
if (Angles == 90) { | ||
return "Right angle"; | ||
} else if (Angles < 90) { | ||
return "Acute angle"; | ||
} else if (Angles == 180) { | ||
return "Straight angle"; | ||
} else if (Angles > 180 && AngleS < 360) { | ||
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. your variable name is not |
||
return "reflex angle"; | ||
} else { | ||
return "it's not angle"; | ||
} | ||
} | ||
var AngleS = 350; | ||
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. small letter for starting variable name. Also use |
||
console.log(getAngleType(AngleS)); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,3 +33,16 @@ | |
// Explanation: The fraction 3/3 is not a proper fraction because the numerator is equal to the denominator. The function should return false. | ||
|
||
// These acceptance criteria cover a range of scenarios to ensure that the isProperFraction function handles both proper and improper fractions correctly and handles potential errors such as a zero denominator. | ||
function isProperFraction(numerator, denominator) { | ||
if (numerator >= denominator && denominator != 0) { | ||
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. you should take care of error first, check if the denomiator is |
||
return "false"; | ||
} else if (numerator < denominator) { | ||
return "True"; | ||
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. a boolean |
||
} else { | ||
return "error"; | ||
} | ||
} | ||
console.log(isProperFraction(5, 2)); | ||
console.log(isProperFraction(3, 0)); | ||
console.log(isProperFraction(-4, 7)); | ||
console.log(isProperFraction(3, 3)); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,3 +38,16 @@ | |
// 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(side1, side2, side3) { | ||
if ( | ||
side1 + side2 <= side3 || | ||
side1 + side3 <= side2 || | ||
(side2 + side3 <= side1 && side1 <= 0) || | ||
side2 <= 0 || | ||
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. why is there no standalone check for side1 |
||
side3 <= 0 | ||
) { | ||
return "false"; | ||
} else { | ||
return "turn"; | ||
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. you are returning |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,29 @@ | |
// Store this expression in a variable and reference it twice in the function in the correct place | ||
|
||
// Explain why it makes more sense to store this expression in a variable | ||
//after storing the expression in variable, there is no need to rewrite the expression | ||
function formatAs12HourClock(time) { | ||
const clockHourIn12 = Number(time.slice(0, 2)); | ||
if (clockHourIn12 > 12) { | ||
return `${clockHourIn12 - 12}:00 pm`; | ||
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. if a value like |
||
} | ||
return `${time} am`; | ||
} | ||
|
||
const currentOutput = formatAs12HourClock("08:00"); | ||
const targetOutput = "08:00 am"; | ||
console.assert( | ||
currentOutput === targetOutput, | ||
"current output: %s, target output: %s", | ||
currentOutput, | ||
targetOutput | ||
); | ||
|
||
const currentOutput2 = formatAs12HourClock("23:00"); | ||
const targetOutput2 = "11:00 pm"; | ||
console.assert( | ||
currentOutput2 === targetOutput2, | ||
"current output: %s, target output: %s", | ||
currentOutput2, | ||
targetOutput2 | ||
); |
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.
start your variable name with a small letter, i.e
angles
instead ofAngles