From c62170aefa2ba51dcc76912defbfea0bee1a8c2b Mon Sep 17 00:00:00 2001 From: alemastas <96082552+alemastas@users.noreply.github.com> Date: Fri, 11 Feb 2022 22:07:13 +0300 Subject: [PATCH 1/3] upload functional --- src/index.js | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index eeae09b1b..1fee5f0c8 100644 --- a/src/index.js +++ b/src/index.js @@ -1,3 +1,78 @@ -module.exports = function toReadable (number) { - +let num = 0; + +module.exports = function toReadable (num) { + + const arrUnits = ['', 'one', 'two', 'three', 'four', 'five', + 'six', 'seven', 'eigth', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', + 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty']; + + const arrDozens = ['', 'one ', 'twenty ', 'thirty ', 'forty ', 'fifty ', + 'sixty ', 'seventy ', 'eighty ', 'ninety ']; + + const arrHundred = ['', 'one hundred ', 'two hundred ', 'three hundred ', 'four hundred ', 'five hundred ', + 'six hundred ', 'seven hundred ', 'eigth hundred ', 'nine hundred ']; + + const arrThousen = ['', 'one thousand ', 'two thousand ', 'three thousand ', 'four thousand ', 'five thousand ', + 'six thousand ', 'seven thousand ', 'eigth thousand ', 'nine thousand ']; + + const arrMillions = ['', 'one million', 'two millions', 'three millions', 'four millions', 'five millions', + 'six millions', 'seven millions', 'eigth millions', 'nine millions', 'ten millions', 'eleven millions', 'twelve millions', 'thirteen millions', + 'fourteen millions', 'fifteen millions', 'sixteen millions', 'seventeen millions', 'eighteen millions', 'nineteen millions', 'twenty millions']; + + function numty(num) { + + let numStr = String(num); + console.log ('numStr length is ' + numStr.length) + + let unitsDozens = +(numStr.slice(-2)); + console.log('units dozens is ' + unitsDozens) + let units = +(numStr.slice(-1)); + // console.log('units is ' + units) + let dozens = +(numStr.slice(-2, -1)); + // console.log('dozens is ' + dozens) + let hundred = +(numStr.slice(-3, -2)); + // console.log('hundred is ' + hundred) + let thousand = +(numStr.slice(-4, -3)); + // console.log('thousand is ' + thousand) + let tenThousen = +(numStr.slice(-5, -4)); + // console.log('ten thousand is ' + thousand) + let combTenThousen = +(numStr.slice(-5,-3)); + //console.log (combTenThousen) + let millions = +(numStr.slice(-6,-5)); + //console.log (arrMillions) + + function comby(unitsDozens) { + if (unitsDozens > 20 && unitsDozens <= 99) { + return `${arrDozens[dozens]}${arrUnits[units]}`; + } else if (unitsDozens <= 20) { + return `${arrUnits[unitsDozens]}` + } + console.log (comby('unitsdozens is true' + unitsDozens)) + } + + console.log ('number is ' + num) + if (num < 22) { + return arrUnits[num] + } + + switch(numStr.length){ + case 2: + return comby(unitsDozens) + break; + case 3: + return `${arrHundred[hundred]}${comby(unitsDozens)}` + break; + case 4: + return `${arrThousen[thousand]}${arrHundred[hundred]}${comby(unitsDozens)}` + break; + case 5: + return `${arrDozens[tenThousen]}${arrThousen[thousand]}${arrHundred[hundred]}${comby(unitsDozens)}` + break; + case 6: + return `${arrHundred[hundred]}${arrDozens[tenThousen]}${arrThousen[thousand]}${arrHundred[hundred]}${comby(unitsDozens)}` + break; + } + } + + return (numty(num)) } From 589b3648a583727719f3e12944e0e28c250ee5a7 Mon Sep 17 00:00:00 2001 From: Aleksandr <96082552+alemastas@users.noreply.github.com> Date: Thu, 17 Feb 2022 19:30:37 +0300 Subject: [PATCH 2/3] fix --- src/index.js | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/src/index.js b/src/index.js index 1fee5f0c8..14dae0123 100644 --- a/src/index.js +++ b/src/index.js @@ -1,8 +1,27 @@ +<<<<<<< HEAD +======= let num = 0; +>>>>>>> c62170aefa2ba51dcc76912defbfea0bee1a8c2b module.exports = function toReadable (num) { const arrUnits = ['', 'one', 'two', 'three', 'four', 'five', +<<<<<<< HEAD + 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', + 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty']; + + const arrDozens = ['', 'one', 'twenty', 'thirty', 'forty', 'fifty', + 'sixty', 'seventy', 'eighty', 'ninety']; + + const arrHundred = ['', 'one hundred', 'two hundred', 'three hundred', 'four hundred', 'five hundred', + 'six hundred', 'seven hundred', 'eight hundred', 'nine hundred']; + + const arrThousen = ['', 'one thousand', 'two thousand', 'three thousand', 'four thousand', 'five thousand', + 'six thousand', 'seven thousand', 'eight thousand', 'nine thousand']; + + const arrMillions = ['', 'one million', 'two millions', 'three millions', 'four millions', 'five millions', + 'six millions', 'seven millions', 'eight millions', 'nine millions', 'ten millions', 'eleven millions', 'twelve millions', 'thirteen millions', +======= 'six', 'seven', 'eigth', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty']; @@ -17,21 +36,77 @@ module.exports = function toReadable (num) { const arrMillions = ['', 'one million', 'two millions', 'three millions', 'four millions', 'five millions', 'six millions', 'seven millions', 'eigth millions', 'nine millions', 'ten millions', 'eleven millions', 'twelve millions', 'thirteen millions', +>>>>>>> c62170aefa2ba51dcc76912defbfea0bee1a8c2b 'fourteen millions', 'fifteen millions', 'sixteen millions', 'seventeen millions', 'eighteen millions', 'nineteen millions', 'twenty millions']; function numty(num) { let numStr = String(num); +<<<<<<< HEAD + // console.log ('numStr length is ' + numStr.length) + + let unitsDozens = +(numStr.slice(-2)); + // console.log('units dozens is ' + unitsDozens) +======= console.log ('numStr length is ' + numStr.length) let unitsDozens = +(numStr.slice(-2)); console.log('units dozens is ' + unitsDozens) +>>>>>>> c62170aefa2ba51dcc76912defbfea0bee1a8c2b let units = +(numStr.slice(-1)); // console.log('units is ' + units) let dozens = +(numStr.slice(-2, -1)); // console.log('dozens is ' + dozens) let hundred = +(numStr.slice(-3, -2)); // console.log('hundred is ' + hundred) +<<<<<<< HEAD + // let thousand = +(numStr.slice(-4, -3)); + // console.log('thousand is ' + thousand) + // let tenThousen = +(numStr.slice(-5, -4)); + // console.log('ten thousand is ' + thousand) + // let combTenThousen = +(numStr.slice(-5,-3)); + //console.log (combTenThousen) + // let millions = +(numStr.slice(-6,-5)); + //console.log (arrMillions) + + function comby(unitsDozens) { + if (unitsDozens == 00) { + return `${''}` + } else if (unitsDozens > 20 && unitsDozens <= 99) { + return `${arrDozens[dozens]}${' '}${arrUnits[units]}`; + } else if (unitsDozens <= 20) { + return `${arrUnits[unitsDozens]}` + } + + // console.log (comby('unitsdozens is true' + unitsDozens)) + } + // console.log ('number is ' + num) + + let combySwitch = `${' '}${comby(unitsDozens)}`; + + let combySwitchDozensUnits = `${arrDozens[dozens]}`; + + (unitsDozens == 00) ? (combySwitch = '') : combySwitch; + + (units == 0) ? (combySwitchDozensUnits) : combySwitchDozensUnits = (`${comby(unitsDozens)}`); + + switch(numStr.length){ + case 2: + return `${combySwitchDozensUnits}` + break; + case 3: + return `${arrHundred[hundred]}${combySwitch}` + break; + case 4: + // return `${arrThousen[thousand]}${' '}${arrHundred[hundred]}${comby(unitsDozens)}` + // break; + // case 5: + // return `${arrDozens[tenThousen]}${arrThousen[thousand]}${arrHundred[hundred]}${comby(unitsDozens)}` + // break; + // case 6: + // return `${arrHundred[hundred]}${arrDozens[tenThousen]}${arrThousen[thousand]}${arrHundred[hundred]}${comby(unitsDozens)}` + // break; +======= let thousand = +(numStr.slice(-4, -3)); // console.log('thousand is ' + thousand) let tenThousen = +(numStr.slice(-5, -4)); @@ -71,6 +146,7 @@ module.exports = function toReadable (num) { case 6: return `${arrHundred[hundred]}${arrDozens[tenThousen]}${arrThousen[thousand]}${arrHundred[hundred]}${comby(unitsDozens)}` break; +>>>>>>> c62170aefa2ba51dcc76912defbfea0bee1a8c2b } } From a14aac151788bd4c97d1c080c819d7de5a637c4e Mon Sep 17 00:00:00 2001 From: Aleksandr <96082552+alemastas@users.noreply.github.com> Date: Thu, 17 Feb 2022 19:38:53 +0300 Subject: [PATCH 3/3] fix[2] --- src/index.js | 72 ++-------------------------------------------------- 1 file changed, 2 insertions(+), 70 deletions(-) diff --git a/src/index.js b/src/index.js index 14dae0123..496bb9a85 100644 --- a/src/index.js +++ b/src/index.js @@ -1,12 +1,7 @@ -<<<<<<< HEAD -======= -let num = 0; ->>>>>>> c62170aefa2ba51dcc76912defbfea0bee1a8c2b module.exports = function toReadable (num) { const arrUnits = ['', 'one', 'two', 'three', 'four', 'five', -<<<<<<< HEAD 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty']; @@ -21,45 +16,22 @@ module.exports = function toReadable (num) { const arrMillions = ['', 'one million', 'two millions', 'three millions', 'four millions', 'five millions', 'six millions', 'seven millions', 'eight millions', 'nine millions', 'ten millions', 'eleven millions', 'twelve millions', 'thirteen millions', -======= - 'six', 'seven', 'eigth', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', - 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty']; - - const arrDozens = ['', 'one ', 'twenty ', 'thirty ', 'forty ', 'fifty ', - 'sixty ', 'seventy ', 'eighty ', 'ninety ']; - - const arrHundred = ['', 'one hundred ', 'two hundred ', 'three hundred ', 'four hundred ', 'five hundred ', - 'six hundred ', 'seven hundred ', 'eigth hundred ', 'nine hundred ']; - - const arrThousen = ['', 'one thousand ', 'two thousand ', 'three thousand ', 'four thousand ', 'five thousand ', - 'six thousand ', 'seven thousand ', 'eigth thousand ', 'nine thousand ']; - - const arrMillions = ['', 'one million', 'two millions', 'three millions', 'four millions', 'five millions', - 'six millions', 'seven millions', 'eigth millions', 'nine millions', 'ten millions', 'eleven millions', 'twelve millions', 'thirteen millions', ->>>>>>> c62170aefa2ba51dcc76912defbfea0bee1a8c2b 'fourteen millions', 'fifteen millions', 'sixteen millions', 'seventeen millions', 'eighteen millions', 'nineteen millions', 'twenty millions']; function numty(num) { let numStr = String(num); -<<<<<<< HEAD // console.log ('numStr length is ' + numStr.length) let unitsDozens = +(numStr.slice(-2)); // console.log('units dozens is ' + unitsDozens) -======= - console.log ('numStr length is ' + numStr.length) - - let unitsDozens = +(numStr.slice(-2)); - console.log('units dozens is ' + unitsDozens) ->>>>>>> c62170aefa2ba51dcc76912defbfea0bee1a8c2b let units = +(numStr.slice(-1)); // console.log('units is ' + units) let dozens = +(numStr.slice(-2, -1)); // console.log('dozens is ' + dozens) let hundred = +(numStr.slice(-3, -2)); // console.log('hundred is ' + hundred) -<<<<<<< HEAD + // let thousand = +(numStr.slice(-4, -3)); // console.log('thousand is ' + thousand) // let tenThousen = +(numStr.slice(-5, -4)); @@ -106,47 +78,7 @@ module.exports = function toReadable (num) { // case 6: // return `${arrHundred[hundred]}${arrDozens[tenThousen]}${arrThousen[thousand]}${arrHundred[hundred]}${comby(unitsDozens)}` // break; -======= - let thousand = +(numStr.slice(-4, -3)); - // console.log('thousand is ' + thousand) - let tenThousen = +(numStr.slice(-5, -4)); - // console.log('ten thousand is ' + thousand) - let combTenThousen = +(numStr.slice(-5,-3)); - //console.log (combTenThousen) - let millions = +(numStr.slice(-6,-5)); - //console.log (arrMillions) - - function comby(unitsDozens) { - if (unitsDozens > 20 && unitsDozens <= 99) { - return `${arrDozens[dozens]}${arrUnits[units]}`; - } else if (unitsDozens <= 20) { - return `${arrUnits[unitsDozens]}` - } - console.log (comby('unitsdozens is true' + unitsDozens)) - } - - console.log ('number is ' + num) - if (num < 22) { - return arrUnits[num] - } - - switch(numStr.length){ - case 2: - return comby(unitsDozens) - break; - case 3: - return `${arrHundred[hundred]}${comby(unitsDozens)}` - break; - case 4: - return `${arrThousen[thousand]}${arrHundred[hundred]}${comby(unitsDozens)}` - break; - case 5: - return `${arrDozens[tenThousen]}${arrThousen[thousand]}${arrHundred[hundred]}${comby(unitsDozens)}` - break; - case 6: - return `${arrHundred[hundred]}${arrDozens[tenThousen]}${arrThousen[thousand]}${arrHundred[hundred]}${comby(unitsDozens)}` - break; ->>>>>>> c62170aefa2ba51dcc76912defbfea0bee1a8c2b + } }