mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2026-03-13 15:21:15 +08:00
fix: standard style issues
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
const pad = (num, padlen) => {
|
||||
var pad = new Array(1 + padlen).join(0)
|
||||
const pad = new Array(1 + padlen).join(0)
|
||||
return (pad + num).slice(-pad.length)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ const orders = [
|
||||
|
||||
function decimalToRoman (num) {
|
||||
let roman = ''
|
||||
for (var symbol of orders) {
|
||||
for (const symbol of orders) {
|
||||
while (num >= values[symbol]) {
|
||||
roman += symbol
|
||||
num -= values[symbol]
|
||||
|
||||
@@ -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