JSFiddle - React, Tailwind, and code Playground
by Ryan Kleinhans
JavaScript
var c1
var c2
var s1 = ["Hearts", "Diamonds", "Spades", "Clubs"]
var s2 = ["Hearts", "Diamonds", "Spades", "Clubs"]
var c1 = Math.floor((Math.random() * 13) + 1)
var suit1 = s1[Math.floor(Math.random()*s1.length)];
var suit2 = s1[Math.floor(Math.random()*s2.length)];
var newC
var newC2
var p1Wins = 26
var p2Wins = 26
var war = 1
while (p1Wins < 51 || p2Wins < 51){
var c1 = Math.floor((Math.random() * 13) + 1)
var s1 = ["Hearts", "Diamonds", "Spades", "Clubs"]
var suit1 = s1[Math.floor(Math.random()*s1.length)];
if (c1 == 13)
newC = ("Ace Of " + suit1);
else if (c1 == 1)
newC = ("2 Of " + suit1)
else if (c1 == 2)
newC = ("3 Of " + suit1)
else if (c1 == 3)
newC = ("4 Of " + suit1)
else if (c1 == 4)
newC = ("5 Of " + suit1)
else if (c1 == 5)
newC = ("6 Of " + suit1)
else if (c1 == 6)
newC = ("7 Of " + suit1)
else if (c1 == 7)
newC = ("8 Of " + suit1)
else if (c1 == 8)
newC = ("9 Of " + suit1)
else if (c1 == 9)
newC = ("10 Of " + suit1)
else if (c1 == 10)
newC = ("Jack Of " + suit1);
else if (c1 == 11)
newC = ("Queen Of " + suit1);
else if (c1 == 12)
newC = ("King Of " + suit1);{
alert("Die")
}
var c2 = Math.floor((Math.random() * 13) + 1)
if (c2 == 13)
newC2 = ("Ace Of " + suit2);
else if (c2 == 1)
newC2 = ("2 Of " + suit2)
else if (c2 == 2)
newC2 = ("3 Of " + suit2)
else if (c2 == 3)
newC2 = ("4 Of " + suit2)
else if (c2 == 4)
newC2 = ("5 Of " + suit2)
else if (c2 == 5)
newC2 = ("6 Of " + suit2)
else if (c2 == 6)
newC2 = ("7 Of " + suit2)
else if (c2 == 7)
newC2 = ("8 Of " + suit2)
else if (c2 == 8)
newC2 = ("9 Of " + suit2)
else if (c2 == 9)
newC2 = ("10 Of " + suit2)
else if (c2 == 10)
newC2 = ("Jack Of " + suit2);
else if (c2 == 11)
newC2 = ("Queen Of " + suit2);
else if (c2 == 12)
newC2 = ("King Of " + suit2);
if (c1 > c2)
{
alert("The computer flipped a " + newC + "\nPlayer 1 flipped a " + newC2 + "\nThe computer wins" + "\n The computer has " + (p1Wins + 1) + " cards left and player 1 has " +...