Battleship

This is a game of Battleship between the user and the CPU.

Battleship

This is a game of battleship.

Rock, Paper, and Scissors

This is a game of rock, paper, and scissors between the CPU and the user. First one to win 10 rounds wins.

Battleship on a Website

This is a game of battleship run on a website. The preview is a bit wonky.

Guessing Game

This is a guessing game in which the user has to guess a number that the CPU is thinking of from 1 to 100 in 5 tries.

Calculator

This is a two number calculator which adds, subtracts, multiplies, and divides two numbers (whole and decimal)/

Game of Rock, Paper, Scissors on a Website

A game of rock, paper, scissors run on a website.

Basic Registeration Prompt

This is a form that asks a series of questions and then records it right below the text box. It isn't fully styled yet, but the functionality is more or less complete.

Guessing Game run on Website

This is a guessing game that is run on a website. The backend was coded in javascript. The submit button checks to see if the number entered in the textBox matches the correct number, the hint button tells you if the number was lower or higher than the last number that you guessed, and the start over button lets you start over whenever you click it. All buttons are disabled upon running out of guesses.

Website Calculator

This is a calculator that is run on a website. Currently, it is only a two number calculator that accepts both decimal and whole numbers.

Game of Battleship in JavaScript

This game of battleship has a 1x1 battleship randomly generated in a 5x5 board. The player has 4 guesses to guess the exact location of the ship. Each miss is marked with a "X" and a "V" is put in place of the battleship's location if you guess it correctly. The coordinates of the ship are given after you run out of guesses.


console.log("Let's play battleship! Try to guess correctly in 4 guesses"); var board = [ ["O", "O", "O", "O", "O"], ["O", "O", "O", "O", "O"], ["O", "O", "O", "O", "O"], ["O", "O", "O", "O", "O"], ["O", "O", "O", "O", "O"] ] console.log(board); function battleship(board, turns){ var compx = Math.floor(Math.random() * 5); var compy = Math.floor(Math.random() * 5); var playerx = prompt("Guess row: "); var playery = prompt("Guess column: "); var i = 1; while (i < (turns)) { if ((compx != playerx && compy != playery) || (compx != playerx && compy == playery) || (compx == playerx && compy != playery)){ board[playerx][playery]= "X"; console.log("You missed my battleship! Turn "+i+" of "+turns); console.log(board); playerx = prompt("Guess row: "); playery = prompt("Guess column: "); } else if (compx == playerx && compy == playery){ board[playerx][playery]= "V"; console.log("You sunk my battleship!"); console.log(board); break; } i+=1; } console.log("The coordinates were "+compx+","+compy); } battleship(board, 4);

Game of Rock, Paper, Scissors in JavaScript

This game of Rock, Paper, Scissors is played between the computer and the user. The choice is given in all lowercase and standard rules for the game apply. After 10 rounds, the scores are tallied and the player with the higher round wins is the winner and the number of wins is displayed at the end.


var choices = ["rock", "paper", "scissors"]; function rps(timesPlayed){ var choices = ["rock", "paper", "scissors"]; var messsage; var final; var playerWins = 0; var compWins = 0; for (var i=0;i<timesPlayed;i++){ var playerChoice = prompt("rock, paper, or scissors? "); var compChoice = choices[Math.floor(Math.random() * choices.length)]; if (playerChoice == "rock" && compChoice == "scissors") { message = "The rock broke the scissors. Player wins!"; playerWins++; } else if (playerChoice == "paper" && compChoice == "rock") { message = "The paper covers the rock. Player wins!"; playerWins++; } else if (playerChoice == "scissors" && compChoice == "paper") { message = "The scissors cut the paper. Player wins!"; playerWins++; } else if (playerChoice == "scissors" && compChoice == "rock") { message = "The rock broke the scissors. Computer wins!"; compWins++; } else if (playerChoice == "paper" && compChoice == "scissors") { message = "The scissors cut the paper. Computer wins!"; compWins++; } else if (playerChoice == "rock" && compChoice == "paper") { message = "The paper covers the rock. Computer wins!"; compWins++; } else if (playerChoice == compChoice) { message = "Draw!"; } console.log(message); } playerWins > compWins ? final = "Player wins! Wins: "+playerWins+"/10" : final = "Computer wins! Wins: "+compWins+"/10"; console.log(final); } rps(10);
1