lodashSandbox: fill
ES6 Enabled
by David McClelland
HTML
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lodash.min.js"></script>
<div class="wrapper">
<div class="title">
<h3>
_.fill
</h3>
</div>
<div class="subtitle">
<h4>
fill an array with incremented elements
</h4>
</div>
<div class="workspace">
<input id='startInput' type='text' value=0 />
<label for="startInput">start</label>
<input id='endInput' type='text' value=10 />
<label for="endInput">end</label>
<div class="actionArea">
<button id="button1">fill</button>
<br />
</div>
<br />
<textarea id="output" rows="2" value="output"></textarea>
</div>
</div>
CSS
label {
font-size: 12px;
}
.wrapper {
display: flex;
flex-direction: column;
width: 500px;
}
.title,
.subtitle,
label {
font-family: Helvetica;
color: gray;
}
.workspace {
display: flex;
flex-direction: column;
}
.actionArea {
border: 1px solid #EEEEEE;
padding: 12px;
}
.actionArea button {
width: 200px;
}
#output {
font-family: Courier;
font-size: 14px;
}
#input1,
#input2 {
font-family: Courier;
font-size: 14px;
}
#modValInput {
font-family: Courier;
font-size: 14px;
}
Babel + JSX
// find elements
let banner = document.getElementById("#playground");
let button = document.getElementById("button");
let startInput = document.getElementById('startInput');
let endInput = parseInt(document.getElementById('endInput').value, 10);
let output = document.getElementById("output");
button1.onclick = () => {
doOperation1();
}
function doOperation1() {
let inputVal = startInput.value;
output.value = _.fill(Array(endInput), startInput.value);
}