Skip to content

Excercise 1 2 3 4 Done~#2

Open
fupuchu wants to merge 1 commit intowdi-sg:masterfrom
fupuchu:master
Open

Excercise 1 2 3 4 Done~#2
fupuchu wants to merge 1 commit intowdi-sg:masterfrom
fupuchu:master

Conversation

@fupuchu
Copy link
Copy Markdown

@fupuchu fupuchu commented May 31, 2018

No description provided.

Comment thread script.js


var result = userNumOne - userNumTwo;
console.log(result);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

But this gives -1 if userNumOne is 1 and userNumTwo is 2, when the difference should be 1... Maybe a if-else statement is needed here to carry out an extra step if the initial result is negative?

Comment thread script.js


var ordinalNum = parseInt(prompt("Provide a number", "0"));
var NumSplit = ordinalNum.split("");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Line 44 throws an error. The .split() method works on strings, but not integers, while in line 43, you've made sure that ordinalNum is an integer...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Would it be better to just prompt the user input as a string in order to split it better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants