Question: CGS 2 8 2 0 Java Script I need help with this assignment: simple codes please nothing fancy, no codes backtick pls . use strict;
CGS Java Script
I need help with this assignment: simple codes please nothing fancy, no codes backtick pls
"use strict";
$function
let ranks AJQK;
let suits HCSD;
let images
preloadImages;
Set a variable called isShuffled to false
Set a variable called numDealt to
Set a variable called numCards to the number of
elements in the images array. You are NOT allowed
to set it to the number Let JavaScript
determine the number of elements.
Set the text inside of the span with ID of numDealtSpan to
Set the text inside of the span with ID of numInDeckSpan to the number of cards.
Assign the function called shuffleDeck to the click event of the button with ID of shuffleBtn.
Assign the function called dealACard to the click event of the button with ID of dealBtn.
$#resetBtn'clickfunction
Set the html of the element with ID of imageArea to the empty string.
Reset the images array to the empty array.
Call the preloadImages function.
Set the isShuffled variable to false.
Set the numDealt variable to
Set the text inside of the span with ID of numDealtSpan to
Set the text inside of the span with ID of numInDeckSpan to the number of cards.
;
function shuffleDeck
Set the html of the element with ID of imageArea to the empty string.
Set the numDealt variable to
Set the text inside of the span with ID of numDealtSpan to
Set the text inside of the span with ID of numInDeckSpan to the number of cards.
Define a variable called numCardsCopy and set its value to the value inside of numCards.
Start a while loop that checks for numCardsCopy bigger than
Define a variable called pos and set it to a call to the function randInt with parameters and numCardsCopy.
Define a variable called card and set it to the element of the images array at index pos.
Set the element of the images array at index pos to the element of the images array at index numCardsCopy
Set the element of the images array at index numCardsCopy to the card variable.
Decrement numCardsCopy by
end while loop
Set isShuffled to true.
function dealACard
Define a variable named imageArea and set its value to the jQuery element with ID of imageArea.
If the number of elements in the array images is do:
Set the html contents of the imageArea variable to the string No more cards in deck."
Get out of the function.
end of the if
If the value in isShuffled is false do:
Set the html contents of the imageArea variable to the string "Shuffle the deck first."
Get out of the function.
end of the if
Define a variable called image and set its value to the first element THINK here of the images array.
Remove the first element of the images array.
Set the html contents of the imageArea variable to the image.
Increment the variable numDealt by
Set the text inside of the span with ID of numDealtSpan to numDealt.
Set the text inside of the span with ID of numInDeckSpan to the number of elements in the images array.
function randIntmin max
Generates a random number between min and max
return Math.floorMathrandommax min min;
function preloadImages
forlet r ; r ranks.length; r
let rank ranksr;
forlet s ; s suits.length; s
let suit suitss;
let imageSrc "PlayingCardImages ranksuitjpg;
let imageTag $;
imageTag.attrsrc imageSrc;
imageTag.attrid ranksuit;
imageTag.attrwidth;
imageTag.attrheight;
images.pushimageTag;
; last thing in the function that does everything
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
