Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4. Write a JavaScript function to compute and return a person's score in the game of 21. Your function must have this header function twentyOne

image text in transcribed

4. Write a JavaScript function to compute and return a person's score in the game of 21. Your function must have this header function twentyOne (hand) The parameter hand is an array that contains integers between 1 and 10, inclusive. The length of the hand array will vary. Your function must add all the integers in the array. If the sum is greater than 21, your function must return the string "bust", otherwise your function must return the sum. For example, if your function were called like this: var cards-[8, 3, 6]; var score twentyone(cards) your function would return the number 17. If your function were called like this: var cards-[1e, 4, 2, 71; var score-twentyOne (cards); your function would return the string "bust

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

6. How do histories influence the process of identity formation?

Answered: 1 week ago