diff --git a/Sprint-3/debug/format-as-12-hours.js b/Sprint-3/debug/format-as-12-hours.js deleted file mode 100644 index 56b83a5b9..000000000 --- a/Sprint-3/debug/format-as-12-hours.js +++ /dev/null @@ -1,30 +0,0 @@ -function formatAs12HourClock(time) { - if (Number(time.slice(0, 2)) > 12) { - return `${Number(time.slice(0, 2)) - 12}:00 pm`; - } - 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 -); - -// formatAs12HourClock currently has a ๐Ÿ› - -// a) Write an assertion to check the return value of formatAs12HourClock when it is called with an input "17:42" -// b) Check the assertion output and explain what the bug is -// c) Now fix the bug and re-run all your assertions diff --git a/Sprint-3/implement/get-card-value.js b/Sprint-3/implement/get-card-value.js index 84723845d..edaeb8275 100644 --- a/Sprint-3/implement/get-card-value.js +++ b/Sprint-3/implement/get-card-value.js @@ -6,7 +6,7 @@ // Acceptance criteria: -// Given a card string in the format "Aโ™ " (representing a card in blackjack), +// Given a card string in the format "Aโ™ " (representing a card in blackjack - the last character will always be an emoji for a suit, and all characters before will be a number 2-10, or one letter of J, Q, K, A), // When the function getCardValue is called with this card string as input, // Then it should return the numerical card value diff --git a/Sprint-3/implement/is-valid-triangle.js b/Sprint-3/implement/is-valid-triangle.js index 432ef338a..f3643ab22 100644 --- a/Sprint-3/implement/is-valid-triangle.js +++ b/Sprint-3/implement/is-valid-triangle.js @@ -1,4 +1,4 @@ -// STRETCH Implement a function isValidTriangle +// Implement a function isValidTriangle // Terms // the Triangle Inequality says: the sum of any two sides is always greater than the third side. // practical examples: @@ -11,15 +11,11 @@ // It's also true that b + c > a // It's also true that a + c > b -// In our function isValidTriangle, we need to invalidate any triangle where the sum of any two sides is less than or equal to the length of the third side. +// In our function isValidTriangle which takes as parameters the lengths of three sides, we need to invalidate any triangle where the sum of any two sides is less than or equal to the length of the third side. // and we need to validate any triangle where the sum of any two sides is greater than the length of the third side. // Acceptance criteria: -// Given the lengths of three sides of a triangle (a, b, c), -// When the function isValidTriangle is called with these side lengths as input, -// Then it should: - // scenario: invalid triangle // Given the side lengths a, b, and c, // When the sum of any two side lengths is less than or equal to the length of the third side (i.e., a + b <= c, a + c <= b, b + c <= a), diff --git a/Sprint-3/implement/rotate-char.js b/Sprint-3/implement/rotate-char.js index 478495a01..e8c961310 100644 --- a/Sprint-3/implement/rotate-char.js +++ b/Sprint-3/implement/rotate-char.js @@ -8,26 +8,26 @@ // Acceptance criteria: -// Given a character (char) and a shift value (shift), +// Given a character and a shift value, // When the function rotateCharacter is called with these inputs, // Then it should: // Scenario: Rotate Lowercase Letters: -// Given a lowercase letter character (char) and a positive integer shift, +// Given a lowercase letter character and a positive integer shift, // When the function is called with these inputs, // Then it should rotate the lowercase letter by shift positions within the lowercase alphabet, wrapping around if necessary, and return the rotated lowercase letter as a string. console.log(rotateCharacter("a", 3)); // Output: "d" -console.log(rotateCharacter("f", 1)); // Output: "f" +console.log(rotateCharacter("f", 1)); // Output: "g" // Scenario: Rotate Uppercase Letters: -// Given an uppercase letter character (char) and a positive integer shift, +// Given an uppercase letter character and a positive integer shift, // When the function is called with these inputs, // Then it should rotate the uppercase letter by shift positions within the uppercase alphabet, wrapping around if necessary, and return the rotated uppercase letter as a string. console.log(rotateCharacter("A", 3)); // Output: "D" console.log(rotateCharacter("F", 1)); // Output: "G" // Scenario: Leave Non-Letter Characters Unchanged: -// Given a character (char) that is not a letter (neither uppercase nor lowercase) and any positive or negative shift value, +// Given a character that is not a letter (neither uppercase nor lowercase) and any positive or negative shift value, // When the function is called with these inputs, // Then it should return the character unchanged. // This specification outlines the behavior of the rotateCharacter function for different input scenarios, including valid and invalid characters, and defines the expected output or action for each case. @@ -39,4 +39,5 @@ console.log(rotateCharacter("7", 5)); // Output: "7" (unchanged, not a letter) // When the rotateCharacter function is called with char and shift as inputs, // Then it should correctly rotate the character by shift positions within the alphabet while handling the wraparound, // And the function should return the rotated character as a string (e.g., 'z' rotated by 3 should become 'c', 'Z' rotated by 3 should become 'C'). -console.log(rotateCharacter("z", 1)); // Output: "a" (unchanged, not a letter) +console.log(rotateCharacter("z", 1)); // Output: "a" (preserves case, but wraps around) +console.log(rotateCharacter("Y", 2)); // Output: "A" (preserves case, but wraps around) diff --git a/Sprint-3/readme.md b/Sprint-3/readme.md index d07219ccf..cd7f34388 100644 --- a/Sprint-3/readme.md +++ b/Sprint-3/readme.md @@ -1,26 +1,11 @@ # ๐Ÿงญ Guide to week 3 exercises -## ๐Ÿ›ย Debug - -First off, `format-as-12-hours.js` has a ๐Ÿ›. - -a) Write an assertion to check the output of `formatAs12HourClock` when it is called with an input `"17:42"` -b) Check the assertion output and try to explain what the bug is - -You'll need to go back and look at some of the functions you implemented in week 2 - write down some assertions to check the functions: - -- Write some assertions down for the function - -## ๐Ÿงน Refactor - -In these problems, you'll be _given_ an implementation and then asked to change it. Once you've updated the implementations you'll need to double check that they are still working! - ## ๐Ÿ”ง Implement In the `implement` directory you've got a number of functions you'll need to implement. For each function, you also have a number of different cases you'll need to check for your function. -Use the acceptance criteria as an aid to **_write assertions_** for the different cases using `console.assert`. Use your assertions to check the functionality you're building as you go along. +Use the acceptance criteria as an aid to **_write tests_** for the different cases using Jest. Use your assertions to check the functionality you're building as you go along. Make sure you cover all edge-cases. Here is a recommended order: @@ -28,7 +13,4 @@ Here is a recommended order: 1. `is-proper-fraction.js` 1. `get-card-value.js` 1. `is-valid-triangle.js` - -## ๐Ÿ’ช Stretch - -Implement `rotateChar` as defined in `implement/rotate-char` +1. `implement/rotate-char` diff --git a/Sprint-3/refactor/format-as-12-hours.js b/Sprint-3/refactor/format-as-12-hours.js deleted file mode 100644 index 5e6f541b2..000000000 --- a/Sprint-3/refactor/format-as-12-hours.js +++ /dev/null @@ -1,5 +0,0 @@ -// There is an implementation of format-as-12-hours.js in the debug directory -// This implementation currently uses the expression Number(time.slice(0, 2)) twice -// 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 diff --git a/Sprint-3/refactor/is-vowel.js b/Sprint-3/refactor/is-vowel.js deleted file mode 100644 index db675d2b5..000000000 --- a/Sprint-3/refactor/is-vowel.js +++ /dev/null @@ -1,42 +0,0 @@ -function isVowel(letter) { - return ( - letter === "a" || - letter === "e" || - letter === "i" || - letter === "i" || - letter === "o" || - letter === "u" - ); -} - -// here is an implementation of isVowel - this function checks if a letter is a vowel - -console.log("case: letter a..."); -const currentOutput = isVowel("a"); -const targetOutput = true; -console.assert( - currentOutput === targetOutput, - "current output: %s, target output: %s", - currentOutput, - targetOutput -); - -console.log("case: letter e..."); -const currentOutput2 = isVowel("e"); -const targetOutput2 = true; -console.assert( - currentOutput2 === targetOutput2, - "current output: %s, target output: %s", - currentOutput2, - targetOutput2 -); - -console.log("case: letter k..."); -const currentOutput3 = isVowel("k"); -const targetOutput3 = false; -console.assert( - currentOutput3 === targetOutput3, - "current output: %s, target output: %s", - currentOutput3, - targetOutput3 -);