-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreversedArray.js
More file actions
21 lines (16 loc) · 797 Bytes
/
reversedArray.js
File metadata and controls
21 lines (16 loc) · 797 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// describe the challenge from CodeWars
document.getElementById('challenge').innerText = 'Given a random non-negative number, you have to return the digits of this number within an array in reverse order.'
// samples: 35231 => [1,3,2,5,3] || 0 => [0]
// the variables
let input = document.getElementById('input')
input.value = "" //clearing the input string on page load
// update the output on input change
input.oninput = function() { reverseArray() }
let outputString = document.getElementById('primus')
// the actual functionality for each challenge goes here
const reverseArray = () => {
outputString.innerText = input.value.split("").reverse()
console.log(outputString.innerText)
}
// testing the entire script runs because I'm a little 'stitious
console.log('Que paso, gato?')