First off, I don’t want you to help me solve this puzzle. Please understand that I know this code is really bad and I suspect that this does not lead to a solution let alone a good solution.
PLEASE DO NOT HELP ME SOLVE THE CHALLENGE
I tried converting an array of strings to an array of numbers using Number()
.
. For some reason when I do this FCC claims that arr.indexOf
is not a function. What is this madness and why does it occur.
arr.indexOf
is in the function assigned to arabicToRomanNumerals. I have left the comment “why?” above the line of code this is written in. Any advice on how to debug this in the future would be greatly appreciated.
Side note: What happened to the chatrooms we used to have?
My code so far
function convertToRoman(num) {
// roman numerals go 3 up and one down
var romanNumerals = ["M","D","C","L","X","V","I"];
var arabicNumerals = [9,8,7,6,5,4,3,2,1,0];
var numArr = Number(String(num).split(""));
var fourLong = function(arr){
if (arr.length < 4){
arr.splice(0,0,0);
fourLong(arr);
}};
fourLong(numArr);
var arabicToRomanNumerals = function(arr, num){
//why?
if(arr.indexOf(num) === 0){
return arr[0] * "M";
}
};
num = arabicToRomanNumerals(numArr, numArr[0]);
return numArr;
}
convertToRoman(1000);
Your browser information:
Your Browser User Agent is: Chrome/60.0.3112.113 Safari/537.36
.
Link to the challenge: