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
| // You are given an array of arrays, where each inner array represents | |
| // the runs scored by each team in an inning of a baseball game: | |
| // [[home1, away1], [home2, away2], ...]. Write a function that returns | |
| // an object with the total runs for each team, which innings each team | |
| // led, and who won the game. | |
| function analyzeBaseballGame(innings) { | |
| let homeTotal = 0; | |
| let awayTotal = 0; | |
| const homeLedInnings = []; |
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
| // Given an array arr representing the positions of monsters | |
| // along a straight line, and an integer d representing the | |
| // minimum safe distance required between any two monsters, | |
| // write a function to determine if all monsters are at least | |
| // d units apart. If not, return the smallest distance found | |
| // between any two monsters. If all monsters are safely spaced, | |
| // return -1. | |
| function minMonsterDistance(arr, d) { | |
| arr.sort((a, b) => a - b); |
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
| // Given an array of side lengths, write a function to determine | |
| // they can form a hexagon with three side-length pairs (as in, | |
| // three pairs of equal sides needed). Return true if possible. | |
| function canFormHexagon(sides) { | |
| if (!Array.isArray(sides) || sides.length !== 6) { | |
| return false; | |
| } | |
| const frequencyMap = {}; |
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
| // Given an array of strings representing the names of monarchs | |
| // and their ordinal numbers, write a function that returns the | |
| // list of names sorted first by name and then by their ordinal | |
| // value (in Roman numerals), in ascending order. | |
| function sortMonarchs(names) { | |
| const romanToInt = (roman) => { | |
| const romanMap = { | |
| I: 1, |
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
| // place in root of project as .vscode/settings.json | |
| { | |
| "workbench.colorCustomizations": { | |
| "titleBar.activeForeground": "#fff", | |
| "titleBar.inactiveForeground": "#000000CC", | |
| "titleBar.activeBackground": "#F40009", | |
| "titleBar.inactiveBackground": "#F40009CC" | |
| }, |
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
| <?php | |
| /* GET OUR WEATHER DATA */ | |
| // Get our JSON | |
| $strJsonFileContents = file_get_contents("YOUR API LINK GOES HERE"); | |
| $weather = json_decode($strJsonFileContents, true); | |
| // Convert temperature and dew point | |
| $temp = round($weather[currently][temperature]) . '°'; |
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
| document.addEventListener("readystatechange", function () { | |
| switch (document.readyState) { | |
| case "complete": | |
| { | |
| // put your code here that will run after the page loads completely. | |
| // if there is "flashing" and complaints are raised you can choose an earlier readyState | |
| // always use "complete" if loading external resources | |
| } | |
| } | |
| }); |