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
// DOM Elements | |
const allCells = document.querySelectorAll('.cell:not(.row-top)'); | |
const topCells = document.querySelectorAll('.cell.row-top'); | |
const resetButton = document.querySelector('.reset'); | |
const statusSpan = document.querySelector('.status'); | |
// columns | |
const column0 = [allCells[35], allCells[28], allCells[21], allCells[14], allCells[7], allCells[0], topCells[0]]; | |
const column1 = [allCells[36], allCells[29], allCells[22], allCells[15], allCells[8], allCells[1], topCells[1]]; | |
const column2 = [allCells[37], allCells[30], allCells[23], allCells[16], allCells[9], allCells[2], topCells[2]]; |
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
* { | |
margin: 0; | |
padding: 0; | |
box-sizing: border-box; | |
} | |
body { | |
align-items: center; | |
background: white; | |
display: flex; |
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 lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" | |
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<link rel="stylesheet" href="style.css"> | |
<title>Connect Four!</title> | |
</head> |
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
* { | |
box-sizing: border-box; | |
margin: 0; | |
padding: 0; | |
} | |
body { | |
display: flex; | |
font-family: sans-serif; | |
justify-content: center; |
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 lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" | |
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<link rel="stylesheet" href="style.css"> | |
<title>Pokedex</title> | |
</head> |
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 pairwise(arr, arg) { | |
const usedDict = {}; | |
let output = 0; | |
for (let i = 0; i < arr.length - 1; i++) { | |
if (usedDict[i]) { | |
continue; | |
} | |
const iVal = arr[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
const getPermutations = arr => { | |
const output = []; | |
const swapInPlace = (arrToSwap, indexA, indexB) => { | |
const temp = arrToSwap[indexA]; | |
arrToSwap[indexA] = arrToSwap[indexB]; | |
arrToSwap[indexB] = temp; | |
}; |
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 updateInventory(arr1, arr2) { | |
const obj1 = arr1.reduce((acc, [amt, name])=>({ | |
...acc, | |
[name]: amt | |
}), {}); | |
const obj2 = arr2.reduce((acc, [amt, name])=>({ | |
...acc, | |
[name]: amt | |
}), {}); |
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 symOfTwo = (arr1, arr2) => { | |
const output = []; | |
for (const el of arr1) { | |
if (!output.includes(el) && !arr2.includes(el)) { | |
output.push(el); | |
} | |
} | |
for (const el of arr2) { | |
if (!output.includes(el) && !arr1.includes(el)) { |
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 symOfTwo = (arr1, arr2) => { | |
const set1 = new Set(arr1); | |
const set2 = new Set(arr2); | |
const combinedArr = [...set1, ...set2]; | |
const elObj = {}; | |
for (const el of combinedArr) { | |
if (el in elObj) { | |
elObj[el]++; |
NewerOlder