{"action":"created","issue":{"url":"https://api.github.com/repos/apuliasoft/j2se-js/issues/10","repository_url":"https://api.github.com/repos/apuliasoft/j2se-js","labels_url":"https://api.github.com/repos/apuliasoft/j2se-js/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/apuliasoft/j2se-js/issues/10/comments","events_url":"https://api.github.com/repos/apuliasoft/j2se-js/issues/10/events","html_url":"https://github.com/apuliasoft/j2se-js/issues/10","id":243345195,"number":10,"title":"Arithmetic Operators","user":{"login":"nsanitate","id":666044,"avatar_url":"https://avatars3.githubusercontent.com/u/666044?v=4","gravatar_id":"","url":"https://api.github.com/users/nsanitate","html_url":"https://github.com/nsanitate","followers_url":"https://api.github.com/users/nsanitate/followers","following_url":"https://api.github.com/users/nsanitate/following{/other_user}","gists_url":"https://api.github.com/users/nsanitate/gists{/gist_id}","starred_url":"https://api.github.com/users/nsanitate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nsanitate/subscriptions","organizations_url":"https://api.github.com/users/nsanitate/orgs","repos_url":"https://api.github.com/users/nsanitate/repos","events_url":"https://api.github.com/users/nsanitate/events{/privacy}","received_events_url":"https://api.github.com/users/nsanitate/received_events","type":"User","site_admin":false},"labels":[{"id":572930356,"url":"https://api.github.com/repos/apuliasoft/j2se-js/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-07-17T09:54:33Z","updated_at":"2017-07-17T19:42:48Z","closed_at":null,"body":"<!--- Provide a general summary of the issue in the Title above -->\r\nImplement the **arithmetic operators** that allow to overcome the differences between Java and JavaScript.\r\n\r\n## Expected Behavior\r\n<!--- If you're describing a bug, tell us what should happen -->\r\n<!--- If you're suggesting a change/improvement, tell us how it should work -->\r\n* Java `a + b` becomes JavaScript `a.add(b)`\r\n* Java `a - b` becomes JavaScript `a.sub(b)`\r\n* Java `a * b` becomes JavaScript `a.mul(b)`\r\n* Java `a / b` becomes JavaScript `a.div(b)`\r\n* Java `a % b` becomes JavaScript `a.rem(b)`\r\n\r\n## Acceptance Test\r\nThe following program tests the arithmetic operators:\r\n```javascript\r\nconst value1 = new Jint(1);\r\nconst value2 = new Jint(2);\r\nconst value8 = new Jint(8);\r\nconst value7 = new Jint(7);\r\n\r\nlet result = value1.add(value2);\r\n// result is now 3\r\nconsole.log(\"1 + 2 = \" + result);\r\nlet original_result = result;\r\n\r\nresult = result.sub(value1);\r\n// result is now 2\r\nconsole.log(original_result + \" - 1 = \" + result);\r\noriginal_result = result;\r\n\r\nresult = result.mul(value2);\r\n// result is now 4\r\nconsole.log(original_result + \" * 2 = \" + result);\r\noriginal_result = result;\r\n\r\nresult = result.div(value2);\r\n// result is now 2\r\nconsole.log(original_result + \" / 2 = \" + result);\r\noriginal_result = result;\r\n\r\nresult = result.add(value8);\r\n// result is now 10\r\nconsole.log(original_result + \" + 8 = \" + result);\r\noriginal_result = result;\r\n\r\nresult = result.rem(value7);\r\n// result is now 3\r\nconsole.log(original_result + \" % 7 = \" + result);\r\n```\r\nOutput:\r\n```\r\n1 + 2 = 3\r\n3 - 1 = 2\r\n2 * 2 = 4\r\n4 / 2 = 2\r\n2 + 8 = 10\r\n10 % 7 = 3\r\n```\r\nThe `+` operator can also be used for concatenating (joining) two strings together, as shown in the following program:\r\n```javascript\r\nvar firstString = new Jstring(\"This is\");\r\nvar secondString = new Jstring(\" a concatenated string.\");\r\nvar thirdString = firstString.add(secondString);\r\nconsole.log(thirdString);\r\n```\r\nOutput:\r\n```\r\nThis is a concatenated string.\r\n```"},"comment":{"url":"https://api.github.com/repos/apuliasoft/j2se-js/issues/comments/315860706","html_url":"https://github.com/apuliasoft/j2se-js/issues/10#issuecomment-315860706","issue_url":"https://api.github.com/repos/apuliasoft/j2se-js/issues/10","id":315860706,"user":{"login":"giuseppe-santoro","id":2903836,"avatar_url":"https://avatars2.githubusercontent.com/u/2903836?v=4","gravatar_id":"","url":"https://api.github.com/users/giuseppe-santoro","html_url":"https://github.com/giuseppe-santoro","followers_url":"https://api.github.com/users/giuseppe-santoro/followers","following_url":"https://api.github.com/users/giuseppe-santoro/following{/other_user}","gists_url":"https://api.github.com/users/giuseppe-santoro/gists{/gist_id}","starred_url":"https://api.github.com/users/giuseppe-santoro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giuseppe-santoro/subscriptions","organizations_url":"https://api.github.com/users/giuseppe-santoro/orgs","repos_url":"https://api.github.com/users/giuseppe-santoro/repos","events_url":"https://api.github.com/users/giuseppe-santoro/events{/privacy}","received_events_url":"https://api.github.com/users/giuseppe-santoro/received_events","type":"User","site_admin":false},"created_at":"2017-07-17T19:42:48Z","updated_at":"2017-07-17T19:42:48Z","body":"What is the meaning of `rem` in `a.rem(b)`?\r\nUsually `a % b` is also written `a mod b`, see: https://en.wikipedia.org/wiki/Modulo_operation\r\n\r\nMy proposal is `a.mod(b)`, what do you think @nsanitate?"}}
{"actor":{"display_login":"giuseppe-santoro"}}