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 render = (vNode) => { | |
if (typeof vNode === 'string') { | |
return document.createTextNode(vNode); | |
} | |
const { tagName, attrs, children } = vNode; | |
const el = document.createElement(tagName); | |
for (const [k, v] of Object.entries(attrs)) { | |
if (/^on/.test(k)) { | |
const eventType = k.replace(/^on/, '').toLowerCase(); | |
el.addEventListener(eventType, v); |
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 createElement = (tagName, { attrs, children }) => { | |
const vEl = Object.create(null); | |
Object.assign(vEl, { | |
tagName, | |
attrs, | |
children, | |
}); | |
return vEl; | |
} |
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
h1 { | |
display: block; | |
text-align: center; | |
} | |
#board { | |
display: block; | |
width: 156px; | |
height: 156px; | |
border: 1px solid #000000; |
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 startGame = () => { | |
let team = 'X'; | |
const board = [ | |
['-', '-', '-'], | |
['-', '-', '-'], | |
['-', '-', '-'], | |
]; | |
const updateBoard = (id) => { | |
switch (id) { | |
case 'tl': |
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
<html> | |
<head> | |
<title>Tic-Tac-Toe</title> | |
<script src="tic-tac-toe.js"></script> | |
<link rel="stylesheet" type="text/css" href="tic-tac-toe.css"> | |
</head> | |
<body> | |
<h1>Tic-Tac-Toe</h1> | |
<div id="board"> | |
<div class="row"> |
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
<html> | |
<head> | |
<title>DOM Homework Page</title> | |
<style> | |
#rectangleWrapper { | |
padding-top: 50px; | |
padding-left: 50px; | |
padding-right: 50px; | |
padding-bottom: 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
const fizzbuzz = () => { | |
let index = 0, max = 100, log = ''; | |
const initialPrimes = [2, 3, 5, 7, 11]; | |
for (; index < max; index++) { | |
if ((index !== 1 && initialPrimes.indexOf(index) !== -1) || | |
(index !== 1 && | |
index % 2 !== 0 && | |
index % 3 !== 0 && | |
index % 5 !== 0 && | |
index % 7 !== 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
const timeAdder = (value1, label1, value2, label2) => { | |
if (typeof value1 !== "number" || typeof value2 !== "number") { | |
console.log("Values must be numbers"); | |
return false; // must be numbers | |
} | |
if (/\./.test(value1) || /\./.test(value2)) { | |
console.log("Values must be integers"); | |
return false; // must be integers | |
} | |
if (value1 < 0 || value2 < 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
/** | |
* All men are mortal | |
* Socrates is a man. | |
* Therefore, socrates is mortal. | |
*/ | |
const Man = function(name) { | |
this.name = name; | |
} |
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
/** | |
* All men are mortal | |
* Socrates is a man. | |
* Therefore, socrates is mortal. | |
*/ | |
const Man = function(name) { | |
this.name = name; | |
}; |
NewerOlder