# Mission accomplished without helpfull functions

**URL:** <https://forum.freecodecamp.org/t/mission-accomplished-without-helpfull-functions/10562>\
**Category:** General\
**Created:** [June 13, 2016, 3:00pm UTC](https://forum.freecodecamp.org/t/mission-accomplished-without-helpfull-functions/10562 "2016-06-13T15:00:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlexanderDom](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/alexanderdom/32/165987_2.png) [@AlexanderDom](https://forum.freecodecamp.org/u/AlexanderDom)\
**Post date:** [June 13, 2016, 3:00pm UTC](https://forum.freecodecamp.org/t/mission-accomplished-without-helpfull-functions/10562/1 "2016-06-13T15:00:18Z")

</div>

Hello,  
I write this topic just to know how **Project Roman Numeral Converter** supposed to be made with Array.splice(), Array.indexOf() and Array.join() because i made it without any of them (spoiler alert it can solve the mission).

Here’s my code (again if you want do it by yourself don’t read that 🙂 ):

```javascript
function convertToRoman(num, newNum) {
  var base = 0;
  if(num/1000 >= 1){
    base = 1000;
  }
  else if(num/100 >= 1){
    base = 100;
  }
  else if(num/10 >= 1){
    base = 10;
  }
  else if(num/10 < 1){
    base = 1;
  }
  
  newNum = newNum ? newNum : '';
  var mainNumber = num/base;
  var modulo = num%base;
  var fifthNumber = '';
  var firstNumber = '';
  var tenthNumber = '';
  switch (base){
    case 1000: firstNumber = "M";
      fifthNumber = 'VV';//i know that it's not exactly this
      tenthNumber = 'XX';//i know that it's not exactly this
      break;
    case 100: firstNumber = "C";
      fifthNumber = 'D';
      tenthNumber = 'M';
      break;
    case 10: firstNumber = "X";
      fifthNumber = 'L';
      tenthNumber = 'C';
      break;
    case 1: firstNumber = "I";
      fifthNumber = 'V';
      tenthNumber = 'X';
      break;
  }
  
  var repetition = Math.floor(mainNumber);
  if(repetition < 4){
    for(var i=0; i<repetition; i++){
      newNum+=firstNumber;
    }
  }
  if(repetition === 4){
    newNum+=firstNumber;
    newNum+=fifthNumber;
  }
  if(repetition > 4 && repetition < 9){
    newNum+=fifthNumber;
    var difference = repetition-5;
    for(var j=0; j<difference; j++){
      newNum+=firstNumber;
    }
  }
  if(repetition === 9){
    newNum+=firstNumber;
    newNum+=tenthNumber;
  }

  if(modulo > 0){
    return convertToRoman(modulo, newNum);
  }else{
    return newNum;
  }
}

```

---

<div class="post-metadata">

**Author:** ![Mizu](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/mizu/32/95363_2.png) [@Mizu](https://forum.freecodecamp.org/u/Mizu)\
**Post date:** [June 13, 2016, 3:53pm UTC](https://forum.freecodecamp.org/t/mission-accomplished-without-helpfull-functions/10562/2 "2016-06-13T15:53:31Z")

</div>

There’s no need to use anything really complex.Your solution works, but is a bit lenghty. Consider two arrays, both of the same length. One has all the romans symbols and the other have the numerical value, in order.

Going through a for loop, I compare the num value with the arrays and when a match is found, i substract this from num.  
You get the correct string value in the end.

If you are curious, [see my code here](https://goo.gl/9SjHVG)

---

<div class="post-metadata">

**Author:** ![AlexanderDom](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/alexanderdom/32/165987_2.png) [@AlexanderDom](https://forum.freecodecamp.org/u/AlexanderDom)\
**Post date:** [June 13, 2016, 4:10pm UTC](https://forum.freecodecamp.org/t/mission-accomplished-without-helpfull-functions/10562/3 "2016-06-13T16:10:07Z")

</div>

Thank you @Mizu, gonna try to do it again (without looking your code before i finished it). I didn’t imagine it with two Arrays at all, i just tried to think about one Array :).

---

<div class="post-metadata">

**Author:** ![jwilkins.oboe](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jwilkins.oboe/32/179497_2.png) [@jwilkins.oboe](https://forum.freecodecamp.org/u/jwilkins.oboe)\
**Post date:** [January 16, 2021, 3:47am UTC](https://forum.freecodecamp.org/t/mission-accomplished-without-helpfull-functions/10562/4 "2021-01-16T03:47:13Z")

</div>

Closed on January 16, 2021, 3:47am UTC


