-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement toRomanNumerals function #32
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job 👏
@@ -1,5 +1,15 @@ | |||
function toRomanNumerals(num) { | |||
return num; | |||
var lookup = { M:1000,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1 }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wulfland, can you please help with the formatting here?
c29cd2b
to
7a67512
Compare
} | ||
} | ||
return roman; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment from mobile app 👍
var i; | ||
for ( i in lookup ) { | ||
while ( num >= lookup[i] ) { | ||
roman += i; | ||
num -= lookup[i]; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var i; | |
for ( i in lookup ) { | |
while ( num >= lookup[i] ) { | |
roman += i; | |
num -= lookup[i]; | |
} | |
} | |
var item; | |
for ( i in lookup ) { | |
while ( num >= lookup[item] ) { | |
roman += item; | |
num -= lookup[item]; | |
} | |
} |
See my solution for the
toRomanNumerals(num)
function.