const romAll = ['M','CM','D','CD','C','XC','L','XL','X','IX','V','IV','I'];
const numAll = [1000,900,500,400,100,90,50,40,10,9,5,4,1];
function roman(all){
let result = ' '
romAll.map( (item, ind) =>{
while (item <= all){
result = numAll[ind];
all = all - item;
}
});
console.log(result)
return result;
};
console.log(roman(5));
function roman(all){
let result = ''
numAll.map( (item, ind) =>{
while (item <= all){
result = result + romAll[ind];
all = all - item;
}
});
return result;
};
function roman(all){
let result = ' '
romAll.map( (item, ind) =>{
console.log(item <= all)//увидишь что для каждой итерации тут false,
//а значит result останется пустой строкой
while (item <= all){
result = numAll[ind];
all = all - item;
}
});
return result;
};