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
| // Author: Mitch Allen | |
| // File: index.js | |
| import { parser } from './parser.js'; | |
| function main() { | |
| let args = process.argv.slice(2); | |
| if (args.length < 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
| { | |
| "type": "object", | |
| "properties": { | |
| "foo": { | |
| "type": "integer" | |
| }, | |
| "bar": { | |
| "type": "string" | |
| } | |
| }, |
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
| { | |
| "foo": 1, | |
| "bar": "abc" | |
| } |
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
| { | |
| "foox": 1, | |
| "bar": "abc" | |
| } |
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
| // Author: Mitch Allen | |
| // File: parser.js | |
| import { readFileSync } from 'fs'; | |
| import Ajv from 'ajv'; | |
| const ajv = new Ajv(); | |
| export function parser(inputFile, schemaFile) { |
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
| // Author: Mitch Allen | |
| // coinflip.js | |
| let coinFlip = () => Math.round(Math.random()); | |
| const LIMIT = 100; | |
| let list = [...Array(LIMIT)].map(() => coinFlip() ? "HEADS" : "TAILS"); | |
| const occurrences = list.reduce(function (acc, curr) { |
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
| // Author: Mitch Allen | |
| // File: pickone.js | |
| let pickOne = (list) => list[Math.floor(Math.random() * list.length)] | |
| let LIMIT = 5; | |
| let list = [...Array(LIMIT)].map(() => Math.random()); | |
| console.log(list); |
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
| // Author: Mitch Allen | |
| // File: js-set.js | |
| const X_SIZE = 100; | |
| let a = [...Array(X_SIZE)].map(() => Math.random().toFixed(2)); | |
| let set = new Set(a); | |
| console.log(a.length); |
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
| // Author: Mitch Allen | |
| // File: coinflip.js | |
| // coinFlip - return a random 1 or 0 | |
| export const coinFlip = () => Math.round(Math.random()); |
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
| // Author: Mitch Allen | |
| // File: test-coinflip.js | |
| import {coinFlip} from './coinflip.js'; | |
| // define test function for coinFlip() | |
| function testCoinFlip() { | |
| // define the number of coin flips to generate | |
| const LIMIT = 100; |