# ES6 Day 2: Homework and correction

**URL:** <https://group.classcentral.com/t/es6-day-2-homework-and-correction/35619>\
**Category:** JavaScript Bootcamp\
**Created:** [September 14, 2022, 9:06am UTC](https://group.classcentral.com/t/es6-day-2-homework-and-correction/35619 "2022-09-14T09:06:14Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![syllie](https://sea2.discourse-cdn.com/flex016/user_avatar/group.classcentral.com/syllie/32/6257_2.png) [@syllie](https://group.classcentral.com/u/syllie)\
**Post date:** [September 17, 2022, 8:17am UTC](https://group.classcentral.com/t/es6-day-2-homework-and-correction/35619/7 "2022-09-17T08:17:51Z")

</div>

Hi Abiola, that is quite a bit to go through.

First of all may I point you to the option to make proper screenshots in future? Windows has a nifty tool built in called the ‘snipping tool’ [https://www.youtube.com/watch?v=2O932t8-k2A](https://www.youtube.com/watch?v=2O932t8-k2A) or its alternative the ‘snip and sketch’ tool [https://www.youtube.com/watch?v=FPXTvrY7yc4](https://www.youtube.com/watch?v=FPXTvrY7yc4) which allows you to make each screenshots that are much better readable for us that want to try and help.

Then let’s go through your code bit by bit.  
‘Selecting from many Options with Switch Statements’ (your picture IMG\_20220916\_163115\_726.jpg and IMG\_20220916\_163041\_019.jpg)

This problem is being discussed here:

> [@Basic JavaScript Day 3: Homework](https://group.classcentral.com/t/basic-javascript-day-3-homework/35089/56):
>
> Hi lexi, You are nearly there! Andre sent you on the right track and you now test ‘val’. If you re-read the instruction, then that should have followed from there: Write a switch statement which tests val and sets answer for the following conditions: So it expects your switch to take the variable val and test that, like so: switch(val){ ... } Then from the table we see the outcome of the test and what answer it should yield: 1 - alpha 2 - beta 3 - gamma 4 - delta If no type is given,…

Take a look and see if that helps you.

The second problem, is kind of the same, but it does require you to understand how a switch works. I have a post here that tries to explain the switch with examples:

> [@Basic JavaScript Day 3: Homework](https://group.classcentral.com/t/basic-javascript-day-3-homework/35089/15):
>
> Hi Bill, The switch statement evaluates an expression, and matches its value in the following case clauses. If it finds a match, it would execute that code block, until it encounters a break (or reaches the end of the switch statement). So you would need to use like this: const quality = 10; // suppose we would judge 1-3 as poor, 4-5 as low, 6-7 medium, 8-10 good // we can now evaluate 'quality' and give our opinion // because multiple ratings can be grouped, we can make use of the 'fall thr…

See if that gives you some understanding, with this clue and the previous assignment I think you may be able to solve it.  
A few tips here:

1. Do not try to just ‘copy’ what you see in the example on the page but look at the construction of the function to start with. See how it gets a parameter _val_ in the function call `function switchOfStuff(val) { ...} ` ? That means we do not know about a ‘num’ but only about a ‘val’, and that is what we should test.
2. There is a default call to the function at the end `switchOfStuff(1);` where you can _see_ that the value that is passed into the function is a number. But then you call it with `console.log(switchOfStuff(a));` how is it to know what `a` is? You did not put it in as the letter a, because that would have been “a”, but like a variable `a` without assigning it.

Your switch statement here in itself is very close to correct though, just have another try after you read the linked posts. I am sure you will get it - if you need more help - just shout out!

Then the Card Counting problem. That is a really tough one, but we also discussed that a few times. See if the above posts in combination with this one help:

> [@Basic JavaScript Day 3: Homework](https://group.classcentral.com/t/basic-javascript-day-3-homework/35089/48):
>
> Hi Lina, I now looked closer at your code, and sorry for not pointing this out earlier, but your case returns a string regardless of the actual value of count. As the count variable lives in the global space, it will keep its value on each call to the function. So to solve this challenge successfully, you need to do this in 2 steps: Evaluate the card and add either +1, 0, -1 to the count variable Evaluate the count variable, and if it is positive, return the current count and Bet, otherwise r…

You may want to browse up a bit in that thread to see Lina’s question too. She was also very close in solving it. Let us know if you need further help with any of these after reading through the posts and trying the exercises again! You got this!

---

_[View the full topic](https://group.classcentral.com/t/es6-day-2-homework-and-correction/35619)._
