Skip to content

Commit

Permalink
Add logic, solve the challenge: finds largest.
Browse files Browse the repository at this point in the history
  • Loading branch information
atom-box committed Sep 5, 2021
1 parent 0437c09 commit 73ea0c9
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 17 deletions.
7 changes: 4 additions & 3 deletions data/quiltData.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ let articles = [
answerHtml: `
<div class="square-small">
<!-- /*==============================*/ -->
<form oninput="out1.value = grub(str1.value)">
<input class="core" type="textarea" name="str1" /><br>
<div class="core stripe"><output name="out1" for="str1">void</output></div>
<form oninput="out1.value = maxEnd3(str1.value)">
<label>Input</label>
<input class="core" type="textarea" name="str1" placeholder="comma separated numbers"/><br>
<div class="stripe"><output name="out1" for="str1" class="gutters stripe">void</output></div>
</form>
<!-- /*==============================*/ -->
</div>
Expand Down
44 changes: 30 additions & 14 deletions helpers/quilt/maxEnd3.mjs
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"
*/
9 changes: 9 additions & 0 deletions quilt.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
margin-bottom: 1rem;
}

.stripe {
text-align: center;
}

/* CSS FONT-DIRECTED no COLOR no POSITIONING */
/* CSS FONT-DIRECTED no COLOR no POSITIONING */
/* CSS FONT-DIRECTED no COLOR no POSITIONING */
Expand Down Expand Up @@ -109,6 +113,11 @@
background-color: blue;
color: white;
}

.stripe {
color: #ccf;
background-color: #000;
}
</style>

<script>
Expand Down

0 comments on commit 73ea0c9

Please sign in to comment.