Best Python code snippet using hypothesis
game_revisiting.js
Source:game_revisiting.js  
1const firstContainer = document.querySelector('#gameButtons')2const secondContainer = document.querySelector('#scores')3const invisibleButton = document.querySelector('button')4let startRound = document.createElement('div');5const updatedResult = document.createElement('div');6const updatedScores = document.createElement('div');7var newcomputerSelection;8var playerScore = 0;9var computerScore = 0;10var drawScore = 0;11const rockbtn = document.querySelector('#rockbtn');12const paperbtn = document.querySelector('#paperbtn');13const scizzorsbtn = document.querySelector('#scizzorsbtn');14// DOM Manipulation15startRound.textContent = "Choose one to play a round of Rock, Paper, Scizzors. First to 5 wins!";16startRound.style.cssText = "border: 2px solid black; font-size: 20px; display:inline-block; padding: 15px;"17updatedScores.textContent = "Your Score:" + " " + playerScore + " | " + "Computer'\s Score:" + " " + computerScore + " | " + "Draws:" + " " + drawScore;18updatedResult.textContent = "Play a round to see the result!"19secondContainer.appendChild(startRound);20secondContainer.appendChild(updatedScores);21secondContainer.appendChild(updatedResult);22// Click event listeners to play the game23rockbtn.addEventListener('click', function (e) {24   let roundResult = playRound('Rock');25    if (roundResult.charAt(4) === 'w'){ // This is used to recognize the outcome from the playRound(); function.26        playerScore++;27        console.log("The score is" + " " + playerScore + " " + "to" + " " + computerScore);28        updatedResult.textContent = "You won! Your opponent chose" + " " + "Scizzors" + " " + "which loses to" + " " + "Rock" + ".";29        updatedScores.textContent = "Your Score:" + " " + playerScore + " | " + "Computer'\s Score:" + " " + computerScore + " | " + "Draws:" + " " + drawScore;30    }31    if (roundResult.charAt(4) === 'l'){32        computerScore++;33        console.log("The score is" + " " + playerScore + " " + "to" + " " + computerScore);34        updatedResult.textContent = "You lost! Your opponent chose" + " " + "Paper" + " " + "which beats" + " " + "Rock" + ".";35        updatedScores.textContent = "Your Score:" + " " + playerScore + " | " + "Computer'\s Score:" + " " + computerScore + " | " + "Draws:" + " " + drawScore;36    }37    if (roundResult.charAt(0) === 'I'){38        drawScore++;39        console.log("No points added to either player. The current score is" + " " + playerScore + " " + "to" + " " + computerScore + ".");40        updatedResult.textContent = "It's a draw! No Points have been added. Your opponent also chose" + " " + "Rock" + ".";41        updatedScores.textContent = "Your Score:" + " " + playerScore + " | " + "Computer's Score:" + " " + computerScore + " | " + "Draws:" + " " + drawScore;42    }43    // Ends the game if either the player or computer reaches a score of 544    if (playerScore === 5) {45        startRound.textContent = "The game has ended. You won! Refresh the page to play again."46        // Makes buttons disappear so you can't play anymore47        rockbtn.style.display = "none";48        paperbtn.style.display = "none";49        scizzorsbtn.style.display = "none";50    } else if (computerScore === 5){51        startRound.textContent = "The game has ended. You lost! Refresh the page to play again."52        // Makes buttons disappear so you can't play anymore53        rockbtn.style.display = "none";54        paperbtn.style.display = "none";55        scizzorsbtn.style.display = "none";56    } 57});58paperbtn.addEventListener('click', function (e) {59    let roundResult = playRound('Paper');60    if (roundResult.charAt(4) === 'w'){ // This is used to recognize the outcome from the playRound(); function.61        playerScore++;62        console.log("The score is" + " " + playerScore + " " + "to" + " " + computerScore);63        updatedResult.textContent = "You won! Your opponent chose" + " " + "Rock" + " " + "which loses to" + " " + "Paper" + ".";64        updatedScores.textContent = "Your Score:" + " " + playerScore + " | " + "Computer'\s Score:" + " " + computerScore + " | " + "Draws:" + " " + drawScore; 65    }66    if (roundResult.charAt(4) === 'l'){67        computerScore++;68        console.log("The score is" + " " + playerScore + " " + "to" + " " + computerScore);69        updatedResult.textContent = "You lost! Your opponent chose" + " " + "Scizzors" + " " + "which beats" + " " + "Paper" + ".";70        updatedScores.textContent = "Your Score:" + " " + playerScore + " | " + "Computer'\s Score:" + " " + computerScore + " | " + "Draws:" + " " + drawScore;71    }72    if (roundResult.charAt(0) === 'I'){73        drawScore++;74        console.log("No points added to either player. The current score is" + " " + playerScore + " " + "to" + " " + computerScore + ".");75        updatedResult.textContent = "It's a draw! No Points have been added. Your opponent also chose" + " " + "Paper" + ".";76        updatedScores.textContent = "Your Score:" + " " + playerScore + " | " + "Computer's Score:" + " " + computerScore + " | " + "Draws:" + " " + drawScore;77    }78     // Ends the game if either the player or computer reaches a score of 579     if (playerScore === 5) {80        startRound.textContent = "The game has ended. You won! Refresh the page to play again."81        // Makes buttons disappear so you can't play anymore82        rockbtn.style.display = "none";83        paperbtn.style.display = "none";84        scizzorsbtn.style.display = "none";85    } else if (computerScore === 5){86        startRound.textContent = "The game has ended. You lost! Refresh the page to play again."87        88        // Makes buttons disappear so you can't play anymore89        rockbtn.style.display = "none";90        paperbtn.style.display = "none";91        scizzorsbtn.style.display = "none";92    } 93});94scizzorsbtn.addEventListener('click', function (e) {95    let roundResult = playRound('Scizzors');96    if (roundResult.charAt(4) === 'w'){ // This is used to recognize the outcome from the playRound(); function.97        playerScore++;98        console.log("The score is" + " " + playerScore + " " + "to" + " " + computerScore);99        updatedResult.textContent = "You won! Your opponent chose" + " " + "Paper" + " " + "which loses to" + " " + "Scizzors" + ".";100        updatedScores.textContent = "Your Score:" + " " + playerScore + " | " + "Computer'\s Score:" + " " + computerScore + " | " + "Draws:" + " " + drawScore;101    }102    if (roundResult.charAt(4) === 'l'){103        computerScore++;104        console.log("The score is" + " " + playerScore + " " + "to" + " " + computerScore);105        updatedResult.textContent = "You lost! Your opponent chose" + " " + "Rock" + " " + "which beats" + " " + "Scizzors" + ".";106        updatedScores.textContent = "Your Score:" + " " + playerScore + " | " + "Computer'\s Score:" + " " + computerScore + " | " + "Draws:" + " " + drawScore;107    }108    if (roundResult.charAt(0) === 'I'){109        drawScore++;110        console.log("No points added to either player. The current score is" + " " + playerScore + " " + "to" + " " + computerScore + ".");111        updatedResult.textContent = "It's a draw! No Points have been added. Your opponent also chose" + " " + "Scizzors" + ".";112        updatedScores.textContent = "Your Score:" + " " + playerScore + " | " + "Computer's Score:" + " " + computerScore + " | " + "Draws:" + " " + drawScore;113    }114     // Ends the game if either the player or computer reaches a score of 5115     if (playerScore === 5) {116        startRound.textContent = "The game has ended. You won! Refresh the page to play again."117        // Makes buttons disappear so you can't play anymore118        rockbtn.style.display = "none";119        paperbtn.style.display = "none";120        scizzorsbtn.style.display = "none";121    } else if (computerScore === 5){122        startRound.textContent = "The game has ended. You lost! Refresh the page to play again."123        124        // Makes buttons disappear so you can't play anymore125        rockbtn.style.display = "none";126        paperbtn.style.display = "none";127        scizzorsbtn.style.display = "none";128    } 129});130// Opponent chooses a hand shape using random number generator131function computerPlay(){132   randomNumber = Math.floor(Math.random()*3) + 1;133    if (randomNumber === 1) {134      return "rock";135    } else if (randomNumber === 2) {136        return "paper";137    } else {138        return "scizzors";139    }140}141// Stores the player and the opponent's hand shape:142function playRound(buttonClicked){143    let newcomputerSelection = computerPlay();144    let playerPrompt = buttonClicked;145    //console.log(playerPrompt);146    let playerSelectionLowerCase = playerPrompt.toLowerCase(); // Makes the prompt input case insensitive, the the rest of the function reads lower case strings.147    //console.log(playerSelectionLowerCase);148    if ((playerSelectionLowerCase === "rock" && newcomputerSelection === "paper") 149    || (playerSelectionLowerCase === "scizzors" && newcomputerSelection === "rock") 150    || (playerSelectionLowerCase === "paper" && newcomputerSelection === "scizzors")) {151        console.log("You lost! Your opponent chose" + " " + newcomputerSelection + " " + "which beats" + " " + playerSelectionLowerCase + ".");152        return "You lost! Your opponent chose" + " " + newcomputerSelection + " " + "which beats" + " " + playerSelectionLowerCase + ".";153        /* I had these two console.log lines to test and make sure that both the player and opponent's hands were being stored correctly in the function.154        console.log(playerSelectionLowerCase);155        console.log(newcomputerSelection); */156    } else if (playerSelectionLowerCase === newcomputerSelection){157        console.log("It's a draw! Your opponent also chose" + " " + newcomputerSelection + ".");158        return "It's a draw! Your opponent also chose" + " " + newcomputerSelection + ".";159        /* I had these two console.log lines to test and make sure that both the player and opponent's hands were being stored correctly in the function.160        console.log(playerSelectionLowerCase);161        console.log(newcomputerSelection); */162    } else if ((playerSelectionLowerCase === "rock" && newcomputerSelection === "scizzors") 163    || (playerSelectionLowerCase === "scizzors" && newcomputerSelection === "paper") 164    || (playerSelectionLowerCase === "paper" && newcomputerSelection === "rock")) {165        console.log("You won! Your opponent chose" + " " + newcomputerSelection + " " + "which loses to" + " " + playerSelectionLowerCase + ".");166        return "You won! Your opponent chose" + " " + newcomputerSelection + " " + "which loses to" + " " + playerSelectionLowerCase + ".";167        /* I had these two console.log lines to test and make sure that both the player and opponent's hands were being stored correctly in the function.168        console.log(playerSelectionLowerCase);169        console.log(newcomputerSelection); */170    } else {171        console.log("Please enter a valid option, the input must be 'rock', 'paper', or 'scizzors' only). This round will count as a draw.");172        return "Please enter a valid option, the input must be 'rock', 'paper', or 'scizzors' only). This round will count as a draw."173        /* I had these two console.log lines to test and make sure that both the player and opponent's hands were being stored correctly in the function.174        console.log(playerSelectionLowerCase);175        console.log(newcomputerSelection); */176    }177}178// FROM MY ORIGINAL ROCK PAPER SCIZZORS PROJECT, DO NOT USE IN THIS REVISITED VERSION!179//  function game() {180//     // Start player's scores at 0.181    182//     let roundOne = playRound();183//     console.log(roundOne); // Lets you know how you won, lost, or drew the round.184//     // Round 1185//     if (roundOne.charAt(4) === 'w'){ // This is used to recognize the outcome from the playRound(); function.186//         playerScore++;187//         console.log("Round 1: The score is" + " " + playerScore + " " + "to" + " " + computerScore);188//     }189//     if (roundOne.charAt(4) === 'l'){190//         computerScore++;191//         console.log("Round 1: The score is" + " " + playerScore + " " + "to" + " " + computerScore);192//     }193//     if (roundOne.charAt(0) === 'I'){194//         console.log("Round 1: No points added to either player. The current score is" + " " + playerScore + " " + "to" + " " + computerScore + ".");195//     }196//     if (roundOne.charAt(0) === 'P'){197//         console.log("Round 1: No points added to either player. The current score is" + " " + playerScore + " " + "to" + " " + computerScore + ".");198//     }199 200//     //Round 2201//     let roundTwo = playRound();202//     console.log(roundTwo);203//     if (roundTwo.charAt(4) === 'w'){204//         playerScore++;205//         console.log("Round 2: The score is" + " " + playerScore + " " + "to" + " " + computerScore);206//     }207//     if (roundTwo.charAt(4) === 'l'){208//         computerScore++;209//         console.log("Round 2: The score is" + " " + playerScore + " " + "to" + " " + computerScore);210//     }211//     if (roundTwo.charAt(0) === 'I'){212//         console.log("Round 2: No points added to either player. The current score is" + " " + playerScore + " " + "to" + " " + computerScore + ".");213//     }214//     if (roundTwo.charAt(0) === 'P'){215//         console.log("Round 2: No points added to either player. The current score is" + " " + playerScore + " " + "to" + " " + computerScore + ".");216//     }217//     // Round 3218//     let roundThree = playRound();219//     console.log(roundThree);220//     if (roundThree.charAt(4) === 'w'){221//         playerScore++;222//         console.log("Round 3: The score is" + " " + playerScore + " " + "to" + " " + computerScore);223//     }224//     if (roundThree.charAt(4) === 'l'){225//         computerScore++;226//         console.log("Round 3: The score is" + " " + playerScore + " " + "to" + " " + computerScore);227//     }228//     if (roundThree.charAt(0) === 'I'){229//         console.log("Round 3: No points added to either player. The current score is" + " " + playerScore + " " + "to" + " " + computerScore + ".");230//     }231//     if (roundThree.charAt(0) === 'P'){232//         console.log("Round 3: No points added to either player. The current score is" + " " + playerScore + " " + "to" + " " + computerScore + ".");233//     }234//     //Round 4235//     let roundFour = playRound();236//     console.log(roundFour);237//     if (roundFour.charAt(4) === 'w'){238//         playerScore++;239//         console.log("Round 4: The score is" + " " + playerScore + " " + "to" + " " + computerScore);240//     }241//     if (roundFour.charAt(4) === 'l'){242//         computerScore++;243//         console.log("Round 4: The score is" + " " + playerScore + " " + "to" + " " + computerScore);244//     }245//     if (roundFour.charAt(0) === 'I'){246//         console.log("Round 4: No points added to either player. The current score is" + " " + playerScore + " " + "to" + " " + computerScore + ".");247//     }248    249//     if (roundFour.charAt(0) === 'P'){250//         console.log("Round 4: No points added to either player. The current score is" + " " + playerScore + " " + "to" + " " + computerScore + ".");251//     }252//     //Round 5253//     let roundFive = playRound();254//     console.log(roundFive);255//     if (roundFive.charAt(4) === 'w'){256//         playerScore++;257//         console.log("Round 5: The final score is" + " " + playerScore + " " + "to" + " " + computerScore);258//     }259//     if (roundFive.charAt(4) === 'l'){260//         computerScore++;261//         console.log("Round 5: The final score is" + " " + playerScore + " " + "to" + " " + computerScore);262//     }263//     if (roundFive.charAt(0) === 'I'){264//         console.log("Round 5: No points added to either player. The final score is" + " " + playerScore + " " + "to" + " " + computerScore + ".");265//     }266//     if (roundFive.charAt(0) === 'P'){267//         console.log("Round 5: No points added to either player. The current score is" + " " + playerScore + " " + "to" + " " + computerScore + ".");268//     }269//     if (playerScore > computerScore) {270//         return "You won the game of 5! The game is now complete, thanks for playing!"271//     } else if (playerScore < computerScore) {272//         return "You lost the game of 5! The game is now complete, thanks for playing!"273//     } else {274//         return "It's a draw! The game is now complete, thanks for playing!"275//     }...stat.js
Source:stat.js  
1import Mock from 'mockjs';2const AllStats = [3    {4        studentno: '2011360114',5        examno: '20110511',6        studentname: 'å¼ æ£å',7        class: 'å
年级 ï¼5) ç',8        subjectScores: {9            score: '82.5',10            classRank: '4',11            gradeRank: '14',12            rank: 'A+'13        },14        totalScores: {15            score: '273.5',16            classRank: '1',17            gradeRank: '1',18            rank: 'A+'19        }20    },21    {22        studentno: '2011360115',23        examno: '20110512',24        studentname: 'åé£',25        class: 'å
年级 ï¼6) ç',26        subjectScores: {27            score: '87.5',28            classRank: '3',29            gradeRank: '8',30            rank: 'A+'31        },32        totalScores: {33            score: '281.5',34            classRank: '1',35            gradeRank: '1',36            rank: 'A+'37        }38    },39    {40        studentno: '2011360116',41        examno: '20110513',42        studentname: 'ç½å¥½è±',43        class: 'å
年级 ï¼7) ç',44        subjectScores: {45            score: '65.5',46            classRank: '7',47            gradeRank: '24',48            rank: 'B+'49        },50        totalScores: {51            score: '225.5',52            classRank: '3',53            gradeRank: '3',54            rank: 'B+'55        }56    },57    {58        studentno: '2011360117',59        examno: '20110514',60        studentname: 'æè¿å',61        class: 'å
年级 ï¼8) ç',62        subjectScores: {63            score: '76.5',64            classRank: '3',65            gradeRank: '16',66            rank: 'A+'67        },68        totalScores: {69            score: '243.5',70            classRank: '2',71            gradeRank: '2',72            rank: 'B+'73        }74    },75    {76        studentno: '2011360118',77        examno: '20110515',78        studentname: 'å¶æ',79        class: 'å
年级 ï¼9) ç',80        subjectScores: {81            score: '78.5',82            classRank: '2',83            gradeRank: '11',84            rank: 'A+'85        },86        totalScores: {87            score: '267.5',88            classRank: '1',89            gradeRank: '1',90            rank: 'A+'91        }92    }93];94const PersonStats = [95    {96        title: 'æåå(2018360247)个人æç»©å',97        scores: [98            {99                examname: '2016å¦å¹´ä¸å¦æ ææ«èè¯',100                subjectScores: [101                    {102                        dictname: 'è¯æ',103                        score: '90'104                    },105                    {106                        dictname: 'æ°å¦',107                        score: '95'108                    },109                    {110                        dictname: 'è±æ',111                        score: '85'112                    },113                    {114                        dictname: 'åå¦',115                        score: '89.5'116                    },117                    {118                        dictname: 'ç©ç',119                        score: '90'120                    }121                ],122                totalScore: '485.5'123            },124            {125                examname: '2017å¦å¹´ä¸å¦æ ææ«èè¯',126                subjectScores: [127                    {128                        dictname: 'è¯æ',129                        score: '75'130                    },131                    {132                        dictname: 'æ°å¦',133                        score: '80'134                    },135                    {136                        dictname: 'è±æ',137                        score: '90'138                    },139                    {140                        dictname: 'åå¦',141                        score: '90.5'142                    },143                    {144                        dictname: 'ç©ç',145                        score: '80'146                    }147                ],148                totalScore: '467.5'149            },150            {151                examname: '2018å¦å¹´ä¸å¦æ ææ«èè¯',152                subjectScores: [153                    {154                        dictname: 'è¯æ',155                        score: '90'156                    },157                    {158                        dictname: 'æ°å¦',159                        score: '95'160                    },161                    {162                        dictname: 'è±æ',163                        score: '85'164                    },165                    {166                        dictname: 'åå¦',167                        score: '89.5'168                    },169                    {170                        dictname: 'ç©ç',171                        score: '90'172                    }173                ],174                totalScore: '485.5'175            },176            {177                examname: '2019å¦å¹´ä¸å¦æ ææ«èè¯',178                subjectScores: [179                    {180                        dictname: 'è¯æ',181                        score: '90'182                    },183                    {184                        dictname: 'æ°å¦',185                        score: '95'186                    },187                    {188                        dictname: 'è±æ',189                        score: '85'190                    },191                    {192                        dictname: 'åå¦',193                        score: '89.5'194                    },195                    {196                        dictname: 'ç©ç',197                        score: '90'198                    }199                ],200                totalScore: '485.5'201            },202            {203                examname: '2020å¦å¹´ä¸å¦æ ææ«èè¯',204                subjectScores: [205                    {206                        dictname: 'è¯æ',207                        score: '90'208                    },209                    {210                        dictname: 'æ°å¦',211                        score: '95'212                    },213                    {214                        dictname: 'è±æ',215                        score: '85'216                    },217                    {218                        dictname: 'åå¦',219                        score: '89.5'220                    },221                    {222                        dictname: 'ç©ç',223                        score: '90'224                    }225                ],226                totalScore: '485.5'227            }228        ]229    },230    {231        title: 'æè¿å(2018360247)个人æç»©å',232        scores: [233            {234                examname: '2016å¦å¹´ä¸å¦æ ææ«èè¯',235                subjectScores: [236                    {237                        dictname: 'è¯æ',238                        score: '90'239                    },240                    {241                        dictname: 'æ°å¦',242                        score: '95'243                    },244                    {245                        dictname: 'è±æ',246                        score: '85'247                    },248                    {249                        dictname: 'åå¦',250                        score: '89.5'251                    },252                    {253                        dictname: 'ç©ç',254                        score: '90'255                    }256                ],257                totalScore: '485.5'258            },259            {260                examname: '2017å¦å¹´ä¸å¦æ ææ«èè¯',261                subjectScores: [262                    {263                        dictname: 'è¯æ',264                        score: '90'265                    },266                    {267                        dictname: 'æ°å¦',268                        score: '95'269                    },270                    {271                        dictname: 'è±æ',272                        score: '85'273                    },274                    {275                        dictname: 'åå¦',276                        score: '89.5'277                    },278                    {279                        dictname: 'ç©ç',280                        score: '90'281                    }282                ],283                totalScore: '485.5'284            },285            {286                examname: '2018å¦å¹´ä¸å¦æ ææ«èè¯',287                subjectScores: [288                    {289                        dictname: 'è¯æ',290                        score: '90'291                    },292                    {293                        dictname: 'æ°å¦',294                        score: '95'295                    },296                    {297                        dictname: 'è±æ',298                        score: '85'299                    },300                    {301                        dictname: 'åå¦',302                        score: '89.5'303                    },304                    {305                        dictname: 'ç©ç',306                        score: '90'307                    }308                ],309                totalScore: '485.5'310            },311            {312                examname: '2019å¦å¹´ä¸å¦æ ææ«èè¯',313                subjectScores: [314                    {315                        dictname: 'è¯æ',316                        score: '90'317                    },318                    {319                        dictname: 'æ°å¦',320                        score: '95'321                    },322                    {323                        dictname: 'è±æ',324                        score: '85'325                    },326                    {327                        dictname: 'åå¦',328                        score: '89.5'329                    },330                    {331                        dictname: 'ç©ç',332                        score: '90'333                    }334                ],335                totalScore: '485.5'336            },337            {338                examname: '2020å¦å¹´ä¸å¦æ ææ«èè¯',339                subjectScores: [340                    {341                        dictname: 'è¯æ',342                        score: '90'343                    },344                    {345                        dictname: 'æ°å¦',346                        score: '95'347                    },348                    {349                        dictname: 'è±æ',350                        score: '85'351                    },352                    {353                        dictname: 'åå¦',354                        score: '89.5'355                    },356                    {357                        dictname: 'ç©ç',358                        score: '90'359                    }360                ],361                totalScore: '485.5'362            }363        ]364    },365    {366        title: 'æé©(2018360247)个人æç»©å',367        scores: [368            {369                examname: '2018å¦å¹´ä¸å¦æ ææ«èè¯',370                subjectScores: [371                    {372                        dictname: 'è¯æ',373                        score: '90'374                    },375                    {376                        dictname: 'æ°å¦',377                        score: '95'378                    },379                    {380                        dictname: 'è±æ',381                        score: '85'382                    },383                    {384                        dictname: 'åå¦',385                        score: '89.5'386                    },387                    {388                        dictname: 'ç©ç',389                        score: '90'390                    }391                ],392                totalScore: '485.5'393            },394            {395                examname: '2019å¦å¹´ä¸å¦æ ææ«èè¯',396                subjectScores: [397                    {398                        dictname: 'è¯æ',399                        score: '90'400                    },401                    {402                        dictname: 'æ°å¦',403                        score: '95'404                    },405                    {406                        dictname: 'è±æ',407                        score: '85'408                    },409                    {410                        dictname: 'åå¦',411                        score: '89.5'412                    },413                    {414                        dictname: 'ç©ç',415                        score: '90'416                    }417                ],418                totalScore: '485.5'419            },420            {421                examname: '2020å¦å¹´ä¸å¦æ ææ«èè¯',422                subjectScores: [423                    {424                        dictname: 'è¯æ',425                        score: '90'426                    },427                    {428                        dictname: 'æ°å¦',429                        score: '95'430                    },431                    {432                        dictname: 'è±æ',433                        score: '85'434                    },435                    {436                        dictname: 'åå¦',437                        score: '89.5'438                    },439                    {440                        dictname: 'ç©ç',441                        score: '90'442                    }443                ],444                totalScore: '485.5'445            },446            {447                examname: '2021å¦å¹´ä¸å¦æ ææ«èè¯',448                subjectScores: [449                    {450                        dictname: 'è¯æ',451                        score: '90'452                    },453                    {454                        dictname: 'æ°å¦',455                        score: '95'456                    },457                    {458                        dictname: 'è±æ',459                        score: '85'460                    },461                    {462                        dictname: 'åå¦',463                        score: '89.5'464                    },465                    {466                        dictname: 'ç©ç',467                        score: '90'468                    }469                ],470                totalScore: '485.5'471            },472            {473                examname: '2022å¦å¹´ä¸å¦æ ææ«èè¯',474                subjectScores: [475                    {476                        dictname: 'è¯æ',477                        score: '90'478                    },479                    {480                        dictname: 'æ°å¦',481                        score: '95'482                    },483                    {484                        dictname: 'è±æ',485                        score: '85'486                    },487                    {488                        dictname: 'åå¦',489                        score: '89.5'490                    },491                    {492                        dictname: 'ç©ç',493                        score: '90'494                    }495                ],496                totalScore: '485.5'497            }498        ]499    }500];...main.js
Source:main.js  
1function getValues(){2    let player1_joker = $(".player1 #joker-amt").val();3    let player2_joker = $(".player2 #joker-amt").val();4    let player3_joker = $(".player3 #joker-amt").val();5    let player4_joker = $(".player4 #joker-amt").val();6    let jv = $("#joker-value").val();7    let player1_placement = $(".player1 #place").val();8    let player2_placement = $(".player2 #place").val();9    let player3_placement = $(".player3 #place").val();10    let player4_placement = $(".player4 #place").val();11    calcAll(player1_joker,player2_joker,player3_joker,player4_joker,player1_placement,player2_placement,player3_placement,player4_placement,jv)12    updateTotalScore()13}14var player1_score = 0;15var player2_score = 0;16var player3_score = 0;17var player4_score = 0;18function updateTotalScore(){19    $(".total-score .player1").html(Math.round(player1_score*100)/100);20    $(".total-score .player2").html(Math.round(player2_score*100)/100);21    $(".total-score .player3").html(Math.round(player3_score*100)/100);22    $(".total-score .player4").html(Math.round(player4_score*100)/100);23}24function calcAll(p1_j,p2_j,p3_j,p4_j,p1_p,p2_p,p3_p,p4_p,j_val){25    let lose_first = 4.5;26    let lose_second = -1;27    let lose_third = -1.5;28    let lose_forth = -2;29    let joker_value = parseFloat(j_val);30    let p1_joker = (parseFloat(p1_j) * joker_value);31    let p2_joker = (parseFloat(p2_j) * joker_value);32    let p3_joker = (parseFloat(p3_j) * joker_value);33    let p4_joker = (parseFloat(p4_j) * joker_value);34    let p1_placement = p1_p;35    let p2_placement = p2_p;36    let p3_placement = p3_p;37    let p4_placement = p4_p;38    //Player 1 earns Joker39    player1_score += p1_joker * 3;40    player2_score -= p1_joker;41    player3_score -= p1_joker;42    player4_score -= p1_joker;43    //Player 2 earns Joker44    player1_score -= p2_joker;45    player2_score += p2_joker * 3;46    player3_score -= p2_joker;47    player4_score -= p2_joker;48    //Player 3 earns Joker49    player1_score -= p3_joker;50    player2_score -= p3_joker;51    player3_score += p3_joker * 3;52    player4_score -= p3_joker;53    //Player 4 earns Joker54    player1_score -= p4_joker;55    player2_score -= p4_joker;56    player3_score -= p4_joker;57    player4_score += p4_joker * 3;58    if(p1_placement == "win"){59        player1_score += 6;60        player2_score -= 2;61        player3_score -= 2;62        player4_score -= 2;63    }else if(p2_placement == "win"){64        player1_score -= 2;65        player2_score += 6;66        player3_score -= 2;67        player4_score -= 2;68    }else if(p3_placement == "win"){69        player1_score -= 2;70        player2_score -= 2;71        player3_score += 6;72        player4_score -= 2;73    }else if(p4_placement == "win"){74        player1_score -= 2;75        player2_score -= 2;76        player3_score -= 2;77        player4_score += 6;78    }else if(p1_placement == "lose" || p2_placement == "lose" || p3_placement == "lose" || p4_placement == "lose"){79        switch (p1_placement){80            case "lose":81                player1_score += lose_forth;82                break;83            case "3":84                player1_score += lose_third;85                break;86            case "2":87                player1_score += lose_second;88                break;89            case "1":90                player1_score += lose_first;91                break;92        }93        switch (p2_placement){94            case "lose":95                player2_score += lose_forth;96                break;97            case "3":98                player2_score += lose_third;99                break;100            case "2":101                player2_score += lose_second;102                break;103            case "1":104                player2_score += lose_first;105                break;106        }107        switch (p3_placement){108            case "lose":109                player3_score += lose_forth;110                break;111            case "3":112                player3_score += lose_third;113                break;114            case "2":115                player3_score += lose_second;116                break;117            case "1":118                player3_score += lose_first;119                break;120        }121        switch (p4_placement){122            case "lose":123                player4_score += lose_forth;124                break;125            case "3":126                player4_score += lose_third;127                break;128            case "2":129                player4_score += lose_second;130                break;131            case "1":132                player4_score += lose_first;133                break;134        }135    }else{136        switch (p1_placement){137            case "4":138                player1_score -= 1.5;139                break;140            case "3":141                player1_score -= 1;142                break;143            case "2":144                player1_score -= 0.5;145                break;146            case "1":147                player1_score += 3;148                break;149        }150        switch (p2_placement){151            case "4":152                player2_score -= 1.5;153                break;154            case "3":155                player2_score -= 1;156                break;157            case "2":158                player2_score -= 0.5;159                break;160            case "1":161                player2_score += 3;162                break;163        }164        switch (p3_placement){165            case "4":166                player3_score -= 1.5;167                break;168            case "3":169                player3_score -= 1;170                break;171            case "2":172                player3_score -= 0.5;173                break;174            case "1":175                player3_score += 3;176                break;177        }178        switch (p4_placement){179            case "4":180                player4_score -= 1.5;181                break;182            case "3":183                player4_score -= 1;184                break;185            case "2":186                player4_score -= 0.5;187                break;188            case "1":189                player4_score += 3;190                break;191        }192    }193    let p1_name = $(".player1 input").val();194    $(".player1 span").html(p1_name);195    $(".player1 input").css("display","none");196    let p2_name = $(".player2 input").val();197    $(".player2 span").html(p2_name);198    $(".player2 input").css("display","none");199    let p3_name = $(".player3 input").val();200    $(".player3 span").html(p3_name);201    $(".player3 input").css("display","none");202    let p4_name = $(".player4 input").val();203    $(".player4 span").html(p4_name);204    $(".player4 input").css("display","none");...app.js
Source:app.js  
1function logText(e) {2    console.log(this.classList.value);3    e.stopPropagation(); // stop bubbling!4    console.log(this);5}6const bulbasaur = document.querySelector('.bulbasaur');7const squirtle = document.querySelector('.squirtle');8const charmander = document.querySelector('.charmander');9bulbasaur.addEventListener('click', playRound)10squirtle.addEventListener('click', playRound)11charmander.addEventListener('click', playRound)12let playerScore = 0;13let compScore = 0;14let roundScore = 0;15// while (playerScore < 5 || compScore < 5) {16function playRound() {17    const myArray = ["bulbasaur", "squirtle", "charmander"];18    const computerSelection = computerPlay();19    let playerSelection = this.classList.value.toUpperCase();20    function computerPlay() {21      y = myArray[~~(Math.random() * myArray.length)].toUpperCase();22      return (y);23    }24    if (computerSelection === "BULBASAUR") {25        if (playerSelection === computerSelection) {26            playerScore = playerScore + 0;27            compScore = compScore + 0;28            roundScore = roundScore + 1;29            var result = ("Bulbasaur vs Bulbasaur, it's a TIE!")30        } else if (playerSelection === "SQUIRTLE") {31            playerScore = playerScore + 0;32            compScore = compScore + 1;33            roundScore = roundScore + 1;34            var result = ("Bulbasaur beats Squirtle, you LOSE!")35        } else {36            playerScore = playerScore + 1;37            compScore = compScore + 0;38            roundScore = roundScore + 1;39            var result = ("Charmander beats Bulbasaur, you WIN!")40        }   41    } else if (computerSelection === "CHARMANDER") {42      if (playerSelection === computerSelection) {43            roundScore = roundScore + 1;44            playerScore = playerScore + 0;45            compScore = compScore + 0;46            var result = ("Charmander vs Charmander, it's a TIE!")47      } else if (playerSelection === "BULBASAUR") {48            roundScore = roundScore + 1;49            playerScore = playerScore + 0;50            compScore = compScore + 1;51            var result = ("Charmander beats Bulbasaur, you Lose!")52      } else {53            roundScore = roundScore + 1;54            playerScore = playerScore + 1;55            compScore = compScore + 0;56            var result = ("Squirtle beats Charmander, you Win!")57        }  58    } else if (computerSelection === "SQUIRTLE") {59      if (playerSelection === computerSelection) {60            roundScore = roundScore + 1;61            playerScore = playerScore + 0;62            compScore = compScore + 0;63            var result = ("Squirtle vs Squirtle, it's a Tie!")64      } else if (playerSelection === "CHARMANDER") {65            roundScore = roundScore + 1;66            playerScore = playerScore + 0;67            compScore = compScore + 1;68            var result = ("Squirtle beats Charmander, You Lose!")69      } else {70            roundScore = roundScore + 1;71            playerScore = playerScore + 1;72            compScore = compScore + 0;73            var result = ("Bulbasaur beats Squirtle, You Win!")74        }  75    }76  console.log(result);77  console.log(roundScore);78  console.log('player score: ' + playerScore);79  console.log('computer score: ' + compScore);80  81  const resultContainer = document.querySelector('.resultContainer');82  83  resultContainer.innerText = "Round " + roundScore + "...FIGHT!" + "\r\n";84  resultContainer.innerText += result + "\r\n";85  resultContainer.innerText += "Player Score: " + playerScore + " vs Computer Score: " + compScore + "\r\n";86  if (playerScore === 5) {87    resultContainer.innerText += "\r\n YOU ARE THE WINNER!";88    roundScore = 0;89    playerScore = 0;90    compScore = 0;91  } else if (compScore === 5) {92    resultContainer.innerText += "\r\n COMPUTER WINS, you LOSE :(";93    roundScore = 0;94    playerScore = 0;95    compScore = 0;96  } 97}98document.getElementsByClassName("playerScore").innerHTML = playRound[0];99// }100// if (playerScore > compScore) {101//     console.log("YOU WIN! :) you beat the computer by scoring "+playerScore +" while the computer only scored " + compScore)102// } else if (playerScore === compScore) {103//     console.log("Ya'll Tie! The final score was "+ playerScore + " vs " + compScore)104// } else {105//     console.log("YOU LOSE :(. The computer beat you by scoring " + compScore + " and you only scored " + playerScore)...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
