Skip to content

Commit

Permalink
revision
Browse files Browse the repository at this point in the history
  • Loading branch information
zelihapala committed Dec 5, 2023
1 parent 5b0383c commit d19bf4a
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 8 deletions.
12 changes: 11 additions & 1 deletion week-3/implement/get-angle-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function getAngleType(angle) {
if (angle < 360) return "Reflex angle";
return "Unknown angle";
}

/*
console.assert(getAngleType(90) === "Right angle", "Right angle");
console.assert(getAngleType(45) === "Acute angle", "Acute angle");
console.assert(getAngleType(120) === "Obtuse angle", "Obtuse angle");
Expand All @@ -42,3 +42,13 @@ console.assert(
getAngleType(400) === "Full angle",
"Full angle or Unknown angle"
);
*/

// I have just wondered and tried with console.log
console.log(getAngleType(180)); // Output: "Straight angle"
console.log(getAngleType(45)); // Output: "Acute angle"
console.log(getAngleType(100)); // Output: "Obtuse angle"
console.log(getAngleType(360)); // Output: "Full angle"
console.log(getAngleType(30)); // Output: "Acute angle"
console.log(getAngleType(270)); // Output: "Reflex angle"
console.log(getAngleType(400)); // Output: "Full angle"
2 changes: 1 addition & 1 deletion week-3/implement/get-card-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function getCardValue(card) {
}
}

console.assert(getCardValue("5♠") === 5, "5 should return 5");
console.assert(getCardValue("5♠") === 7, "5 should return 5"); // i wanted to see assertion message
console.assert(getCardValue("J♦") === 10, "J should return 10");
console.assert(getCardValue("A♣") === 11, "A should return 11");
console.assert(() => getCardValue("P♠"), new Error("Invalid card rank"));
11 changes: 10 additions & 1 deletion week-3/implement/is-proper-fraction.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function isProperFraction(numerator, denominator) {
return false;
} else if (numerator < 0 && Math.abs(numerator) < denominator) {
return true;
// condition checks if the fraction has a negative numerator. The Math.abs() function finds the absolute value, which is the positive size or amount of a number, no matter if it's negative or positive. So, for a negative number, its absolute value gives the positive size of that number.
} else if (numerator === denominator) {
return false;
}
Expand All @@ -59,6 +60,14 @@ console.assert(

console.assert(isProperFraction(-4, 7) === true, "Negative Fraction failed");
console.assert(
isProperFraction(3, 3) === false,
isProperFraction(3, 3) === false, // to see assertion message we can change (7,8)
"Equal Numerator and Denominator failed"
);

/*
isProperFraction(2, 3) → It's a proper fraction because the numerator is less than the denominator. The test should return true.
isProperFraction(5, 2) → This is not a proper fraction because the numerator is greater than or equal to the denominator. The test should return false.
isProperFraction(3, 0) → It should return an error because the denominator is zero.
isProperFraction(-4, 7) → It's a proper fraction because the numerator is negative and its absolute value is less than the denominator. The test should return true.
isProperFraction(3, 3) → This is not a proper fraction because the numerator and the denominator are equal. The test should return false.
*/
14 changes: 12 additions & 2 deletions week-3/refactor/format-as-12-hours.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,18 @@ console.assert(

function formatAs12HourClock(time) {
let hours = Number(time.slice(0, 2));
let minutes = Number(time.slice(time.indexOf(":") + 1));
// let minutes = Number(time.slice(time.indexOf(":") + 1));
// find indexOf(":") this character and add 1 or move to next and get minutes and turn it to number
let minutes = Number(time.slice(3, 5)); // looks like easier

if (hours > 12) {
return `${(hours - 12).toString().padStart(2, "0")}:${minutes} pm`;
return `${(hours - 12).toString().padStart(2, "0")}:${minutes
.toString()
.padStart(2, "0")} pm`;
}
return `${time} am`;
}
// toString takes number and makes it string and padStart() adds characters to the start here it is 0 so it will be like this 9 will be 09

const currentOutput = formatAs12HourClock("08:00");
const targetOutput = "08:00 am";
Expand All @@ -64,3 +69,8 @@ console.assert(
currentOutput3 === targetOutput3,
`${currentOutput3} and ${targetOutput3}`
);

console.log(
currentOutput3 === targetOutput3,
`${currentOutput3} and ${targetOutput3}` // working
);
5 changes: 2 additions & 3 deletions week-3/refactor/is-vowel.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ function isVowel(letter) {
letter === "u"
);
}
// letter = i used twice it doesn't change the function but can confuse and make the code harder to read. I deleted one of them and codes work.

// here is an implementation of isVowel - this function checks if a letter is a vowel

Expand All @@ -21,7 +22,7 @@ console.assert(
);

console.log("case: letter e...");
const currentOutput2 = isVowel("e");
const currentOutput2 = isVowel("l"); // here I Intentionally made a mistake
const targetOutput2 = true;
console.assert(
currentOutput2 === targetOutput2,
Expand All @@ -39,5 +40,3 @@ console.assert(
currentOutput3,
targetOutput3
);

// letter = i used twice it doesn't change the function but can confuse and make the code harder to read. I deleted one of them and codes work.

0 comments on commit d19bf4a

Please sign in to comment.