JavaScript Algorithms and Data Structures Projects - Roman Numeral Converter

Tell us what’s happening:

my array.from(arr) is returning an empty array that I am creating using the object numerals. please help

Your code so far

// function convertToRoman(num) {

// }
// convertToRoman(36);

let numerals = {
  1000: "M",
	900: "CM",
  500: "D",
	400: "CD",
  100: "C",
	90: "XC",
  50: "L",
	40: "XL",
  10: "X",
	9: "IX",
  5: "V",
	4: "IV",
  1: "I"
};
let arr = Array.from(numerals);
console.log(arr);
console.log(Array.isArray(arr), arr.length);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36

Challenge Information:

JavaScript Algorithms and Data Structures Projects - Roman Numeral Converter

Welcome back to the forum @skullcoder08

console.log(typeof(arr)); // object

Here is an Array.from() article you may find helpful.

Note the above console.log

Happy coding

I have already read this article before posting but still couldn’t understand why is it returning an empty array . I consoled the code you provided and it’s returning object meaning that my arr is treated as an object not as array…why? Please help.

To convert an ordinary object that’s not iterable or array-like to an array (by enumerating its property keys, values, or both), use Object.keys(), Object.values(), or Object.entries().

You can’t use Array.from on an object

Oh ok ! Thanks for clearing my concept, till now I thought the object(numerals) is iterable.