Looking for more info? Follow our learning guides and get started!

List the all the cards in a deck of cards


<html> <head> </head> <body> <script> var types = ["clubs", "diamonds", "hearts", "spades"]; var values = ["ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "jack", "queen", "king"]; for (var i =1;i<=52;i++) { printCardRevised(i); } function printCard(num) { var tempnum = num; if (num <= 13) { document.write(types[0], values[num - 1]); } else if (num > 13 && num <= 26) { tempnum = tempnum - 13; document.write(types[1], values[tempnum - 1]); tempnum = num; } else if (num > 26 && num <= 39) { tempnum = tempnum - 26; document.write(types[2], values[tempnum - 1]); tempnum = num; } else { tempnum = tempnum - 39; document.write(types[3], values[tempnum - 1]); tempnum = num; } document.write("<br>"); } function printCardRevised(num) { var suit; var face; face = num %13; suit = parseInt(num/13); if (face ==0) { face = 13; suit--; } document.write(types[suit], values[face -1]); document.write("<br>"); } </script> </body> </html>

Loading Please Wait...