- calculate({ num1, num2, operation })
+ calculate(num1, num2, operation)
- switch (OPERATIONS)
+ switch (operation)
<textarea></textarea>
<button class="save">Сохранить</button>
<button class="clear">Очистить</button>
let textarea = document.querySelector('textarea')
let save = document.querySelector('.save')
let clear = document.querySelector('.clear')
save.addEventListener('click', function(){
localStorage.setItem('value', textarea.value)
})
clear.addEventListener('click', function(){
localStorage.removeItem('value')
})
localStorage.getItem('value') !== null
? textarea.value = localStorage.getItem('value')
: textarea.value = ''
translateZ
значение половины высоты контейнера:translateZ(30px)
function cll(){
var div = document.getElementById('img_div');
var div_new = document.createElement('div')
div_new.id = '1';
var img = document.createElement('img');
img.src ='lalalaalalalal';
img.classList.add("image");
div.appendChild(div_new);
div_new.appendChild(img);
}
cll()
let sum = [];
function hw(arr) {
for (let i = 0; i < arr.length; i++) {
let value = arr[i].toString();
((arr[i] % 3 == 0) || (value.substr(value.length-1, value.length) == 5)) ? sum.push(arr[i]) : '';
}
sum.length == 0 ? console.log('Элементов нет') : result = sum.reduce((prev, val)=>{return console.log(prev * val);});
};
hw([46, 47, 10, 10, 20, 47, 15, 48, 2, 16])
<div class='element'>
</div>
.element{
display: flex;
width: 20px;
height: 20px;
background-color: #000;
}
.not-active{
display: none;
}
document.querySelector('.element').classList.toggle('not-active')
let theForm = document.forms["form"];
let theForm = document.querySelector('.form');
<button id="mainbutton">Создать фигуру</button>
<script>
let colors = ['red', 'green', 'blue'];
$(document).on('click', '#mainbutton', function(){
let div = document.createElement('div')
let size = Math.floor((Math.random()*100)+5);
let randomColor = colors[Math.floor(Math.random()*colors.length)]
$(div).css("width", size+"px")
$(div).css("height", size+"px")
$(div).css('backgroundColor', randomColor)
document.body.append(div)
});
</script>