Battleship

Player vs AI there are 20 rounds each player has a 1 by 1 ship

Rock Paper Scissors

The computer randomly selects a number which corresponds to rock paper or scissors. Then the program compares all the possible combinations to determine who the winner is.

Rock Paper Scissors

This is a game of rock paper scissors with the CPU. The user is prompted to choose rock, paper, or scissor and then the CPU randomly selects one of the three. Afterwards the winner is outputted to the console. The main part of the code was the nested "if" statements to check for all the possible outcomes that could result between the user and the CPU.

var player1 = prompt("Choose Rock, Paper, or Scissors "); var x = Math.random(); if (x < 1/3){ x = "rock"; } else if(x <= 2/3) { x = "paper"; } else { x = "scissors"; } var result = function(a, b) { if(a === b) { return "It's a draw"; } if(a === "rock") { if(b === "scissors") { return "rock wins"; } else { return "paper wins"; } } if(a === "paper") { if(b === "rock") { return "paper wins"; } else { if(b === "scissors") { return "scissors wins"; } } if(a === "scissors") { if(b === "rock") { return "rock wins"; } else { if(b === "paper") { return "scissors wins"; } } } } }; console.log("Player1: " + player1); console.log("x: " + x); result(player1, x);

Simple Calculator

This is a simple calculator with basic operations(Adding, Subtracting, Multiplying, Dividing).

1