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
·42 lines (34 loc) · 870 Bytes
/
script.js
File metadata and controls
executable file
·42 lines (34 loc) · 870 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
37
38
39
40
41
' use strict '
var display = document.getElementById('display')
function yourFunctionName (){
display.innerHTML = "hello"
}
function example () {
var v = 3 + 4
display.innerHTML = v
}
function combineArrays(arrOne, arrTwo) {
let arrCombined = []
for (let i = 0; i < arrOne.length; i++) {
arrCombined.push(arrOne[i])
arrCombined.push(arrTwo[i])
}
display.innerHTML = arrCombined
}
function getFirstDigit (num) {
let digitString = ('' + num)[0]
let digit = parseInt(digitString)
return digit
}
function compare (numOne, numTwo) {
const digitOne = getFirstDigit(numOne)
const digitTwo = getFirstDigit(numTwo)
if (digitOne < digitTwo) return 1
if (digitOne > digitTwo) return -1
else return 0
}
function formLargestNum (arrPosInt) {
console.log(arrPosInt)
arrPosInt.sort(compare)
display.innerHTML += arrPosInt.join('')
}