Do you ever find yourself struggling to articulate your thoughts? I can certainly relate to that sentiment at the moment. Today’s coding session proved challenging, as I encountered some obstacles. Nevertheless, I successfully completed the Dice Game project and have begun working on a new endeavor known as the FCC author page project. Interestingly, I had to look up what the FCC stood for, even though I should’ve known. As it turns out, it stands for Federal Communications Commission, which may not be relevant to the project but serves as helpful information.
We got Merlin a shedding brush that brushes out all the shedding hairs. It’s pretty cool, and wow, he sheds a lot. I tried it on Mimi, but she wasn’t a fan. Of course, Mimi doesn’t shed.
I’ve been recommended the book “Safe People,” but I’m finding it challenging. The book explores the concept of safe relationships and their impact on emotional well-being and personal growth. However, the many biblical quotes make it difficult for me to separate the religious aspects from the psychological concepts. While it’s true that many psychological ideas have their roots in religious or spiritual traditions, it can be challenging to disentangle the two, particularly when exploring topics like forgiveness, meaning-making, or mindfulness. Nonetheless, contemporary psychology generally attempts to extract universal principles and practices from religious contexts and study them secularly. I’m just looking for one page with no bible quotes, as I believe that self-help books can exist without discussing religion.
I’m still getting into the book. There are a lot of definitions of unsafe people, but I would like to know what makes a safe person and how to be one. Maybe that will be later in the book.
JavaScript notes…
—————————————-
FreeCodeCamp Dice Game steps 76 – 87
Step 76
If the user did not get a Full house then the option for None of the above should be enabled with 0 points awarded.
Below your if statement, call the updateRadioOption function and pass in the numbers 5 and 0 for the arguments.
if (hasThreeOfAKind && hasPair) { updateRadioOption(2, 25); } updateRadioOption(5, 0);
Step 77
To see the results of your detectFullHouse function, call your detectFullHouse function inside the rollDiceBtn event listener and pass in the diceValuesArr variable for the argument.
Try playing a few rounds of the game to see if you can land on a Full house.
detectFullHouse(diceValuesArr);
Step 78
For the last portion of the game, you will need to create an algorithm that checks for the presence of a straight.
A small straight is when four of the dice have consecutive values(Ex. 1234) resulting in a score of 30 points. A large straight is when all five dice have consecutive values(Ex. 12345) resulting in a score of 40 points.
Start by creating an arrow function called checkForStraights that has arr for the parameter name.
const checkForStraights = (arr) => { }
Step 79
To check for a small or large straight, you will need to first sort the list of numbers in the array.
Use the sort method on the arr parameter and pass in a callback function. For the callback function, use a and b for the parameters and implicitly return a – b.
Assign that entire result to a const variable called sortedNumbersArr.
const checkForStraights = (arr) => { const sortedNumbersArr = arr.sort((a, b) => a - b); };
Step 80
To check for only unique numbers, you will need to use a Set on your sortedNumbersArr. Convert that result into an array using the spread operator.
Lastly, assign that entire result to a const variable called uniqueNumbersArr.
const uniqueNumbersArr = [...new Set(sortedNumbersArr)];
Step 81
Next, use the join method on the uniqueNumbersArr and assign that result to a const variable called uniqueNumbersStr. For the join method use an empty string for the separator.
const uniqueNumbersStr = uniqueNumbersArr.join("")
Step 82
There are a total of 3 possibilities for a small straight: “1234”, “2345”, and “3456”.
Create a const variable called smallStraightsArr and assign it the value of an array containing the three string values listed above.
const smallStraightsArr = ["1234", "2345", "3456"]
Step 83
There are only two possibilities for a large straight: “12345” and “23456”.
Create a const variable called largeStraightsArr and assign it the value of an array containing the two string values listed above.
const largeStraightsArr = ["12345", "23456"]
Step 84
If the user rolls a large straight, then the Large straight radio button option should be enabled with a score of 40 points.
Start by creating an if statement to check if uniqueNumbersStr is included in the largeStraightsArr. If so, call the updateRadioOption with 4 and 40 for the arguments.
if (largeStraightsArr.includes(uniqueNumbersStr)) { updateRadioOption(4, 40); }
Step 85
If the user rolls a small straight, then the Small straight radio button option should be enabled with a score of 30 points. A small straight consists of four separate dice rolls arranged in numerical order.
To get started, iterate through smallStraightsArr using any loop you prefer. If using a higher-order function like forEach or some, the callback function should take an argument of straight. If using for…of, the loop variable should also be straight.
Inside the loop, if uniqueNumbersStr has a combination that matches a small straight, call the updateRadioOption with 3 and 30 as the arguments.
smallStraightsArr.forEach(straight => { if (uniqueNumbersStr.includes(straight)) { updateRadioOption(3, 30); } });
Step 86
If the user does not get a small or large straight, call the updateRadioOption function and pass in the numbers 5 and 0 for the arguments.
else if (!isSmallStraight) { updateRadioOption(5, 0); }
Step 87
To see the results of your checkForStraights function, call your checkForStraights function inside the rollDiceBtn event listener and pass in the diceValuesArr variable for the argument.
And with that last change, you have completed your dice game!
checkForStraights(diceValuesArr)