Skip to content

Instantly share code, notes, and snippets.

View sirdarthvader's full-sized avatar
🤷‍♂️
console.log(NaN === NaN); //-> false

Ashish Singh sirdarthvader

🤷‍♂️
console.log(NaN === NaN); //-> false
View GitHub Profile
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';
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!'))
@sirdarthvader
sirdarthvader / colorGame-initial state index.html
Created June 3, 2018 23:16
Initial html file for colorGame
<!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>
<!DOCTYPE html>
<html>
<head>
<title>Color Game</title>
<link rel="stylesheet" type="text/css" href="app.css">
</head>
<body>
<h1>
The Great
<br>
body {
background-color: #232323;
margin: 0;
font-family: "Montserrat", "Avenir";
}
h1 {
text-align: center;
line-height: 1.1;
font-weight: normal;
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)",
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);
// Reset Game...
resetButton.addEventListener('click', function(){
colors = generateRandomColors(6);
pickedColor = pickColor();
for(i=0; i<=squares.length; i++) {
squares[i].style.backgroundColor = colors[i];
}
})
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;
}
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 + ")";
}