skip to Main Content

How to shuffle cards in javascript?

let cards = ["A","2","3","4","5","7","8","9","10","J","Q","K"]; shuffle(cards); console.log(cards); function shuffle(array){ let currentindex = array.length; while (currentindex !=0) { let randomcards = Math.floor(Math.random()* array.length) currentindex -=1; let temp = array[currentindex]; array[currentindex] = array[randomcards]; array[randomcards] = temp} return array } My teacher taught me…

VIEW QUESTION

Javascript – Sorting an array of objects by date with some dates being null

I have a huge array of objects called steamData that look like this: { "sid": 1690, "store_url": "https://store.steampowered.com/app/1690", "store_promo_url": null, "store_uscore": 69, "published_store": "2006-10-16", "published_meta": "2006-10-16", "published_stsp": "2006-10-16", "published_hltb": "2020-04-18", "published_igdb": "2006-09-01", "image": "https://steamcdn-a.akamaihd.net/steam/apps/1690/header.jpg", "name": "Space Empires V", "description": "Space…

VIEW QUESTION
Back To Top
Search