function convert(num) {
return num;
}
convert(36);
Convert the given number into a roman numeral.hint [1/6]
Make sure you've tried to hard to solve it yourself before proceeding. :construction:
type
hint
for next hint :pencil: [Contribute at the FCC Wiki]
hint [2/6]
type
hint
for next hint :pencil: [Contribute at the FCC Wiki]
hint [3/6]
type
hint
for next hint :pencil: [Contribute at the FCC Wiki]
hint [4/6]
type
hint
for next hint :pencil: [Contribute at the FCC Wiki]
hint [5/6]
type
hint
for next hint :pencil: [Contribute at the FCC Wiki]
hint [6/6]
Solution ahead!
var convert = function(num) {
// Create arrays with default conversion with matching indices.
var decimalValue = [ 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 ];
var romanNumeral = [ 'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I' ];
//empty string variable for the final roman number
var romanized = '';
// Loop through the indices of the decimalValue array.
for (var index = 0; index < decimalValue.length; index++) {
// Continue to loop while the value at the current index will fit into numCopy
while (decimalValue[index] <= num) {
// Add the Roman numeral & decrease numCopy by the decimal equivalent.
romanized += romanNumeral[index];
num -= decimalValue[index];
}
}
return romanized;
};
If you found this page useful, you can give thanks by copying and pasting this on the main chat:Thanks @Rafase282 @SaintPeter @benschac
NOTE: Please add your username only if you have added any relevant main contents to the wiki page. (Please don't remove any existing usernames.)
type
hint
for next hint :pencil: [Contribute at the FCC Wiki]
function convert(num) {
return num;
}
convert(36);
Convert the given number into a roman numeral.
more info:
bf details
|bf links
|hint
hint [1/6]
Make sure you've tried to hard to solve it yourself before proceeding. :construction:
type
hint
for next hint :pencil: [Contribute at the FCC Wiki]
hint [2/6]
type
hint
for next hint :pencil: [Contribute at the FCC Wiki]
hint [3/6]
type
hint
for next hint :pencil: [Contribute at the FCC Wiki]
hint [4/6]
type
hint
for next hint :pencil: [Contribute at the FCC Wiki]
hint [5/6]
type
hint
for next hint :pencil: [Contribute at the FCC Wiki]
hint [6/6]
Solution ahead!
var convert = function(num) {
// Create arrays with default conversion with matching indices.
var decimalValue = [ 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 ];
var romanNumeral = [ 'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I' ];
//empty string variable for the final roman number
var romanized = '';
// Loop through the indices of the decimalValue array.
for (var index = 0; index < decimalValue.length; index++) {
// Continue to loop while the value at the current index will fit into numCopy
while (decimalValue[index] <= num) {
// Add the Roman numeral & decrease numCopy by the decimal equivalent.
romanized += romanNumeral[index];
num -= decimalValue[index];
}
}
return romanized;
};
If you found this page useful, you can give thanks by copying and pasting this on the main chat: Thanks @Rafase282 @SaintPeter @benschac for your help with Bonfire: Roman Numeral Converter
NOTE: Please add your username only if you have added any relevant main contents to the wiki page. (Please don't remove any existing usernames.)
type
hint
for next hint :pencil: [Contribute at the FCC Wiki]
hint [1/6]
Make sure you've tried to hard to solve it yourself before proceeding. :construction:
type
hint
for next hint :pencil: [Contribute at the FCC Wiki]
hint [2/6]
type
hint
for next hint :pencil: [Contribute at the FCC Wiki]
hint [3/6]
type
hint
for next hint :pencil: [Contribute at the FCC Wiki]
hint [4/6]
type
hint
for next hint :pencil: [Contribute at the FCC Wiki]
hint [5/6]
type
hint
for next hint :pencil: [Contribute at the FCC Wiki]
hint [6/6]
Solution ahead!
var convert = function(num) {
// Create arrays with default conversion with matching indices.
var decimalValue = [ 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 ];
var romanNumeral = [ 'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I' ];
//empty string variable for the final roman number
var romanized = '';
// Loop through the indices of the decimalValue array.
for (var index = 0; index < decimalValue.length; index++) {
// Continue to loop while the value at the current index will fit into numCopy
while (decimalValue[index] <= num) {
// Add the Roman numeral & decrease numCopy by the decimal equivalent.
romanized += romanNumeral[index];
num -= decimalValue[index];
}
}
return romanized;
};
If you found this page useful, you can give thanks by copying and pasting this on the main chat: Thanks @Rafase282 @SaintPeter @benschac for your help with Bonfire: Roman Numeral Converter
NOTE: Please add your username only if you have added any relevant main contents to the wiki page. (Please don't remove any existing usernames.)
type
hint
for next hint :pencil: [Contribute at the FCC Wiki]
hint [1/6]
Make sure you've tried to hard to solve it yourself before proceeding. :construction:
type
hint
for next hint :pencil: [Contribute at the FCC Wiki]
hint [2/6]
type
hint
for next hint :pencil: [Contribute at the FCC Wiki]
hint [3/6]
type
hint
for next hint :pencil: [Contribute at the FCC Wiki]