mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 16:26:47 +08:00
fix: standard style issues
This commit is contained in:
@ -1,18 +1,16 @@
|
||||
function hexToInt (hexNum) {
|
||||
const numArr = hexNum.split('') // converts number to array
|
||||
numArr.map((item, index) => {
|
||||
if (!(item > 0)) {
|
||||
switch (item) {
|
||||
case 'A': return (numArr[index] = 10)
|
||||
case 'B': return (numArr[index] = 11)
|
||||
case 'C': return (numArr[index] = 12)
|
||||
case 'D': return (numArr[index] = 13)
|
||||
case 'E': return (numArr[index] = 14)
|
||||
case 'F': return (numArr[index] = 15)
|
||||
}
|
||||
} else numArr[index] = parseInt(item)
|
||||
return numArr.map((item, index) => {
|
||||
switch (item) {
|
||||
case 'A': return 10
|
||||
case 'B': return 11
|
||||
case 'C': return 12
|
||||
case 'D': return 13
|
||||
case 'E': return 14
|
||||
case 'F': return 15
|
||||
default: return parseInt(item)
|
||||
}
|
||||
})
|
||||
return numArr // returns an array only with integer numbers
|
||||
}
|
||||
|
||||
function hexToDecimal (hexNum) {
|
||||
@ -23,9 +21,3 @@ function hexToDecimal (hexNum) {
|
||||
}
|
||||
|
||||
export { hexToInt, hexToDecimal }
|
||||
|
||||
// > hexToDecimal('5DE9A'))
|
||||
// 384666
|
||||
|
||||
// > hexToDecimal('3D'))
|
||||
// 61
|
||||
|
Reference in New Issue
Block a user