-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add logic, solve the challenge: finds largest.
- Loading branch information
Showing
3 changed files
with
43 additions
and
17 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,34 @@ | ||
// window.addEventListener('DOMContentLoaded', (event) => { | ||
// const btn = document.getElementById('maxEnd3Button'); | ||
// btn.addEventListener('click', alert('whipping')); | ||
let dice = {}; | ||
dice.roll5 = function() { | ||
return Math.ceil(5 * Math.random()); | ||
let maxEnd3 = function(inString){ | ||
let inNumbers = inString.split(','); | ||
console.log(`type of inArray is [${typeof inNumbers}] value is [${inNumbers}`); | ||
first = Number(inNumbers[0]); | ||
last = Number(inNumbers[inNumbers.length-1]); | ||
let roleModel = last; | ||
if(first > last){ | ||
roleModel = first; | ||
} | ||
let plateauedNums = inNumbers.map((x) => {return roleModel}); | ||
let outString = plateauedNums.toString(); | ||
return outString; | ||
} | ||
|
||
dice.show5 = function() { | ||
// dice.el = document.getElementById('diceout'); | ||
console.log( dice.roll5()); | ||
} | ||
|
||
console.log('end maxEnd3.mjs.'); | ||
|
||
// }); | ||
/* | ||
PSEUDOCODE | ||
Store input as a string | ||
string to array, let inputNums = stringInput.split(','); | ||
first = inputNums[0]; | ||
last = inputNums[nums.length()-1] | ||
let roleModel = null; | ||
roleModel = last; | ||
if (first > last){roleModel = first} | ||
let plateauedNums = inputNums.map((x) => {return roleModel}); | ||
array to string stringOutput = nums.toString()); | ||
return stringOutput; | ||
*/ | ||
|
||
// THIS does not NEED ANY SPECIAL WRAPPER; Its scope will be fine that way. The wrapper blocks its scope otherwise. | ||
/* | ||
Dev reflection: Wasted time doing incorrect comparison because data was string, not number. | ||
Unseen coercion! | ||
e.g. was finding that "3" is greater than "6" | ||
*/ |
This file contains 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