Как сделать страницу где будет считать 1000-7 до 6
Типу:
1000-7=993
993-7=986
986-7=979
и т.д.
Ответы (2 шт):
Автор решения: De.Minov
→ Ссылка
Допустим так
let a = 1000, b = 7;
while(a-b >= 0) {
document.body.innerHTML += `${a}-${b} = ${a = a-b}<br>`;
}
body {font-size: 12px}
Ну или так
let a = 1000, b = 7,
str = document.querySelector('#str'),
ms = 150;
let timer = setTimeout(function tick() {
if(a-b >= 0) {
str.innerText = `${a}-${b} = ${a = a-b}`;
timer = setTimeout(tick, ms);
} else clearTimeout(timer);
}, ms);
body {
display: flex;
justify-content: center;
align-items: center;
font-size: 10vw;
width: 100%;
min-height: 100vh;
margin: 0;
}
<div id="str"></div>
Автор решения: Leonid
→ Ссылка
Или так, например.
<form oninput="result.value = `${+a.value + 7} - 7 = ${a.value}`" style="display:flex;font:20px sans-serif">
<input type="range" name="a" max="993" min="6" step="7" value="993" style="flex:1 1 auto">
<output name="result" style="width:7em;text-align:right">1000 - 7 = 993</output>
</form>