From e7ddb8300acf162712b276a421b2b493e2e5958a Mon Sep 17 00:00:00 2001 From: ma-oliveiramarques Date: Wed, 30 Mar 2022 14:22:39 +0100 Subject: [PATCH 1/2] Add feature sum two numbers const num1 & num2, return --- src/sum-two-numbers.js | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/sum-two-numbers.js diff --git a/src/sum-two-numbers.js b/src/sum-two-numbers.js new file mode 100644 index 0000000..63c0466 --- /dev/null +++ b/src/sum-two-numbers.js @@ -0,0 +1,9 @@ +// to store input numbers +const num1 = parseInt(prompt('Enter the first number:')); +const num2 = parseInt(prompt('Enter the second number:')); + +function sum(num1, num2) { + return num1 + num2; +} + +sum(); \ No newline at end of file From fe5a26de95d020de166077bd3e8d8cc10156d367 Mon Sep 17 00:00:00 2001 From: ma-oliveiramarques Date: Wed, 30 Mar 2022 18:15:16 +0100 Subject: [PATCH 2/2] install npm & add sum feature --- package.json | 20 ++++++++++++++++++++ src/sum-two-numbers.js | 8 +++++--- 2 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 package.json diff --git a/package.json b/package.json new file mode 100644 index 0000000..f2b24eb --- /dev/null +++ b/package.json @@ -0,0 +1,20 @@ +{ + "name": "javascript-calculator", + "version": "1.0.0", + "description": "From zero to FullStack - an unofficial course led by [Pedro Soares](https://github.com/pncsoares) with the aim of guiding and helping two friends to learn programming and become software developers.", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/from-zero-to-fullstack/javascript-calculator.git" + }, + "keywords": [], + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/from-zero-to-fullstack/javascript-calculator/issues" + }, + "homepage": "https://github.com/from-zero-to-fullstack/javascript-calculator#readme" +} diff --git a/src/sum-two-numbers.js b/src/sum-two-numbers.js index 63c0466..67dffc2 100644 --- a/src/sum-two-numbers.js +++ b/src/sum-two-numbers.js @@ -1,9 +1,11 @@ + // to store input numbers -const num1 = parseInt(prompt('Enter the first number:')); -const num2 = parseInt(prompt('Enter the second number:')); +const num1 = 5; +const num2 = 10; function sum(num1, num2) { return num1 + num2; } -sum(); \ No newline at end of file +const x = sum(num1, num2); +console.log(x); \ No newline at end of file