Skip to content

Elyses Looping Enchantments: Guide students to use the correct concept #2666

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

Merged
merged 1 commit into from
Jun 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ To keep things simple, she only uses cards with values 1-10.
Elyse wants to know how many cards of a particular type she has in her deck.

Write a function `cardTypeCheck` that takes two parameters: an array of cards (Elyse's deck) and the type of card to count.

<!--prettier-ignore -->
~~~exercism/note
The function should use `forEach` and return the number of cards in the deck of the specified type.
~~~

```javascript
const cardType = 3;
Expand All @@ -23,7 +27,11 @@ For another trick, Elyse needs to know how many odd or even cards there are in h
Implement a function `determineOddEvenCards` that takes in two parameters: an array of cards (Elyse's deck), and a boolean (true is analogous to 'even', and false is analogous to 'odd').

This function should return a single number: the number of odd or even cards there are (depending on the value of the second argument) in the deck.

<!--prettier-ignore -->
~~~exercism/note
To practice, use a `for...of` loop in the function implementation this time.
~~~

```javascript
determineOddEvenCards([1, 2, 3, 1, 5, 6], true);
Expand Down
2 changes: 2 additions & 0 deletions exercises/concept/elyses-looping-enchantments/enchantments.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @returns {number} number of cards of a single type there are in the deck
*/
export function cardTypeCheck(stack, card) {
// 🚨 Use .forEach
throw new Error('Implement the cardTypeCheck function');
}

Expand All @@ -20,5 +21,6 @@ export function cardTypeCheck(stack, card) {
* @returns {number} number of cards that are either odd or even (depending on `type`)
*/
export function determineOddEvenCards(stack, type) {
// 🚨 Use a `for...of` loop
throw new Error('Implement the determineOddEvenCards function');
}