Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions ch3_pull-request/Create-PullRequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ In Chapter 3 - _Teamwork and Collaborative Development_ we learn how to collabo

2. Delete the following line:

__Delete this line__

3. Add one or two lines here with a random text:

__...__
Add random text
a new line
Add another line

4. Modify the following line by removing the letters that do not belong:

__---> The ccow jumpedd ovverr thhe mooon__
__---> The cow jumped over the moon__

5. Commit your changes into a new _branch_:

Expand Down
12 changes: 11 additions & 1 deletion ch3_pull-request/src/app.js
Original file line number Diff line number Diff line change
@@ -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 };
Copy link
Collaborator Author

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?

var roman = '';
var i;
for ( i in lookup ) {
while ( num >= lookup[i] ) {
roman += i;
num -= lookup[i];
}
}
Comment on lines +4 to +10
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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];
}
}

return roman;

Copy link
Owner

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 numbers = [3,4,5,13,42,2021];
Expand Down