This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const canvas = document.querySelector('#canvas'); | |
| const ctx = canvas.getContext('2d'); | |
| canvas.width = window.innerWidth; | |
| canvas.height = window.innerHeight; | |
| ctx.strokeStyle = '#BADA55'; | |
| ctx.lineWidth = 1; | |
| ctx.lineJoin = 'round'; | |
| ctx.lineCap = 'round'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const express = require('express') | |
| const app = express() | |
| app.get('/', (req, res) => res.send('Hello World!')) | |
| app.listen(3000, () => console.log('Example app listening on port 3000!')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
| <title>Color Game</title> | |
| <meta name="description" content=""> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <link rel="stylesheet" href="app.css"> | |
| </head> | |
| <body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Color Game</title> | |
| <link rel="stylesheet" type="text/css" href="app.css"> | |
| </head> | |
| <body> | |
| <h1> | |
| The Great | |
| <br> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| body { | |
| background-color: #232323; | |
| margin: 0; | |
| font-family: "Montserrat", "Avenir"; | |
| } | |
| h1 { | |
| text-align: center; | |
| line-height: 1.1; | |
| font-weight: normal; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var numSquares = 6; | |
| var pickedColor; | |
| var squares = document.querySelectorAll(".square"); | |
| var messageDisplay = document.querySelector("#message"); | |
| var resetButton = document.querySelector("#reset"); | |
| var modeButtons = document.querySelectorAll(".mode"); | |
| var colors = [ | |
| "rgb(255, 0, 0)", | |
| "rgb(0, 255, 0)", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var numSquares = 6; | |
| var pickedColor; | |
| var squares = document.querySelectorAll(".square"); | |
| var systemMessageDisplay = document.querySelector("#default-code"); | |
| var userMessageDisplay = document.querySelector("#user-code"); | |
| var resetButton = document.querySelector("#reset"); | |
| var modeButtons = document.querySelectorAll(".mode"); | |
| var header = document.querySelector('#header'); | |
| var colors = generateRandomColors(6); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Reset Game... | |
| resetButton.addEventListener('click', function(){ | |
| colors = generateRandomColors(6); | |
| pickedColor = pickColor(); | |
| for(i=0; i<=squares.length; i++) { | |
| squares[i].style.backgroundColor = colors[i]; | |
| } | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function generateRandomColor(num) { | |
| //make an array | |
| var arr = []; | |
| // run the randomColor function num times | |
| for (i=0; i < num ; i++) { | |
| arr.push(randomColors()); | |
| } | |
| // return an array | |
| return arr; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function randomColor(){ | |
| //pick a "red" from 0 - 255 | |
| var r = Math.floor(Math.random() * 256); | |
| //pick a "green" from 0 -255 | |
| var g = Math.floor(Math.random() * 256); | |
| //pick a "blue" from 0 -255 | |
| var b = Math.floor(Math.random() * 256); | |
| return "rgb(" + r + ", " + g + ", " + b + ")"; | |
| } |