const arr = [{a:5},{d:6},{g:0},{b:3},{c:1}];
let max = null;
let result;
for (const currentObj of arr) {
const currentValue = currentObj[Object.keys(currentObj)[0]];
const currentKey = Object.keys(currentObj)[0];
if (max < currentObj[currentKey] || max === null) {
max = currentValue;
result = currentKey;
}
}
console.log(result);
if (input1 > input2) {
let temp = input2;
input2 = input1;
input1 = temp;
}
<div class="all">
<span class="one">1</span>
<span class="one">2</span>
<span class="one">3</span>
<span class="one">4</span>
</div>
<input type="text" class="project_val" />
const spansWrapper = document.querySelector('.all');
const input = document.querySelector('.project_val');
const copyTextFromClickedSpanToInput = e => {
if (e.target.classList.contains('one')) {
input.value = e.target.innerText;
}
}
spansWrapper.addEventListener('click', e => copyTextFromClickedSpanToInput(e));
function range(start, end) {
const arr = [];
for (let i = start; i <= end; i++) {
arr.push(i);
}
return arr;
}
console.log(range(1, 10));
<div class="container">
<div class="a"></div>
<div class="b"></div>
</div>
.container {
width: 500px;
height: 500px;
position: relative;
}
.a {
display: none;
width: 500px;
height: 500px;
background-color: black;
clip-path: polygon(10% 0%, 100% 0%, 100% 100%, 0% 100%, 0% 10%);
position: absolute;
top: 0;
left: 0;
}
.b {
width: 494px;
height: 494px;
background-color: yellow;
position: absolute;
top: 3px;
left: 3px;
clip-path: polygon(10% 0%, 100% 0%, 100% 100%, 0% 100%, 0% 10%);
}
.container:hover .a {
display: block;
}
<p>Date: <input type="text" id="datepicker"></p>
$( function() {
$( "#datepicker" ).datepicker();
} );
for(var i = 0; i <= 23; i++){
if (i < 10) {
console.log('0' + i + ' ');
}
else {
console.log(i + ' ');
}
}
<input type="text" id="a" value="aaa">
var inp = document.getElementById('a');
inp.addEventListener('input', function () {
if(inp.value.length <= 3) {
inp.value = 'aaa';
}
});