T.T.T.32: COUNT WITH YOUR FINGERS

Subscribers:
4,890
Published on ● Video Link: https://www.youtube.com/watch?v=XXiRiLA4ezA



Duration: 3:40
23 views
2


Complete the function which accepts an integer, and returns the name of the finger on which the counting will end: "Thumb", "Index finger", "Middle finger", "Ring finger", or "Little finger".

EXPLANATION CODE:
1) The function uses an array with a length of 8 and an index for each key on the keyboard. The members of the array stand in for the fingers that press the keys; the first element represents the finger that presses key 0, the second element represents the finger that presses key 1, and so forth.

2)The bitwise AND operator & with 7 (which is equivalent to n% 8 in this context) is used by the function to determine the input n's remainder when divided by 8. This makes sure that the input value always falls within the array's valid range.

3) The element of the array at the determined index, which indicates the finger used to press the associated key, is then returned by the function.

Contents:
0:00 - Reading
0:50 - Solving
2:50 - Explaining
#codewars #code #wars #javascript #ttt #with #your #fingers #javascriptprogramming programming #education #tutorial #computerscience #puzzles #games







Tags:
codewars
code
wars
tutorial
step by step
education
computer science
explanation
7kyu
another
card
game
algorithms
games
javascript
javascript programming
ttt 32 count with your fingers
ttt
32
count
with
your
fingers