Skip to content

Instantly share code, notes, and snippets.

@fitsum
Last active April 26, 2024 05:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fitsum/8afd6a6df69f88b254f9e6c4be262697 to your computer and use it in GitHub Desktop.
Save fitsum/8afd6a6df69f88b254f9e6c4be262697 to your computer and use it in GitHub Desktop.
const r = document.querySelector('input[type="range"]'),
initVal = 20,
story = [];
let currVal = null;
r.value = initVal;
r.addEventListener('change', (e) => {
let finalVal = e.target.value,
message = finalVal === currVal ? currVal : "Error";
console.clear();
console.log('Final:', message);
console.table(story);
}, false);
r.addEventListener('input', (e) => {
currVal = e.target.value;
story.push({'value': currVal, 'time': new Date().getTime()})
/* console.log('Currently:', currVal) */
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment