forked from iyasu/Java2JavaScript-Lab-3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
executable file
·36 lines (31 loc) · 874 Bytes
/
script.js
File metadata and controls
executable file
·36 lines (31 loc) · 874 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
' use strict '
var display = document.getElementById('display')
function arrangeArray () {
display.innerHTML = ''
const arrayOne = ['a', 'b', 'c']
const arrayTwo = ['1', '2', '3']
for (let i = 0; i < arrayOne.length; i++) {
display.innerHTML += arrayOne[i]
display.innerHTML += '<br/>' + arrayTwo[i] + '<br/>'
}
}
function format (number) {
let value = 0
if (number >= 10) value = number / 10
else if (number >= 100) value = number / 100
else if (number >= 1000) value = number / 1000
else return number
return Math.round(value)
}
function compare (a, b) {
const aFormatted = format(a)
const bFormatted = format(b)
if (aFormatted > bFormatted) return -1
if (aFormatted < bFormatted) return 1
return 0
}
function highestNumber () {
const numbers = [50, 2, 1, 9]
numbers.sort(compare)
display.innerHTML += numbers.join('')
}