From 809d8011820336c61fad3a8c1d9a43bfa18ccde8 Mon Sep 17 00:00:00 2001 From: Paola Date: Tue, 28 Jul 2020 14:34:28 -0500 Subject: [PATCH] challenge solved --- .gitignore | 104 +++++++++++++++++++++++++++++++++++++ .huskyrc | 5 ++ LICENSE | 21 ++++++++ README.md | 26 ++++++++++ package.json | 32 ++++++++++++ src/__test__/index.test.js | 7 +++ src/index.js | 5 ++ 7 files changed, 200 insertions(+) create mode 100644 .gitignore create mode 100644 .huskyrc create mode 100644 LICENSE create mode 100644 README.md create mode 100644 package.json create mode 100644 src/__test__/index.test.js create mode 100644 src/index.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6704566 --- /dev/null +++ b/.gitignore @@ -0,0 +1,104 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test + +# parcel-bundler cache (https://parceljs.org/) +.cache + +# Next.js build output +.next + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and *not* Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port diff --git a/.huskyrc b/.huskyrc new file mode 100644 index 0000000..0526a23 --- /dev/null +++ b/.huskyrc @@ -0,0 +1,5 @@ +{ + "hooks": { + "pre-commit": "npm test" + } +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..55a1b6d --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Platzi Master + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..c464c61 --- /dev/null +++ b/README.md @@ -0,0 +1,26 @@ +# challenge-javascript-01 - Area of a Triangle + +Escribe una función que tome la base y la altura de un triángulo y devuelva su área. + +### Instalación +``` +npm install +``` + +### test +``` +npm run test +``` + +### RETO + +Completa la función para calcular el área de un triángulo. + +### Enviar solución de reto +Debes hacer un "Fork" de este proyecto, revolver los problemas y crear un Pull Request hacia este repositorio. + +### Contribuir +Si alguien quiere agregar o mejorar algo, lo invito a colaborar directamente en este repositorio: [challenge-javascript-01](https://github.com/platzimaster/challenge-javascript-01/) + +### Licencia +challenge-javascript-01 se lanza bajo la licencia [MIT](https://opensource.org/licenses/MIT). diff --git a/package.json b/package.json new file mode 100644 index 0000000..7b82143 --- /dev/null +++ b/package.json @@ -0,0 +1,32 @@ +{ + "name": "challenge-js-01", + "version": "1.0.0", + "description": "Area of a Triangle", + "main": "index.js", + "scripts": { + "test": "jest" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/PlatziMaster/challenge-js-01.git" + }, + "keywords": [ + "JavaScript" + ], + "author": "Oscar Barajas ", + "license": "MIT", + "bugs": { + "url": "https://github.com/PlatziMaster/challenge-js-01/issues" + }, + "homepage": "https://github.com/PlatziMaster/challenge-js-01#readme", + "devDependencies": { + "husky": "^4.2.1", + "jest": "^24.9.0" + }, + "jest": { + "verbose": true, + "transformIgnorePatterns": [ + "/(node_modules)/" + ] + } +} \ No newline at end of file diff --git a/src/__test__/index.test.js b/src/__test__/index.test.js new file mode 100644 index 0000000..d7ff638 --- /dev/null +++ b/src/__test__/index.test.js @@ -0,0 +1,7 @@ +const triangleArea = require('../index'); + +describe('Test Triangle Area Function', () => { + test('Calculate Area', () => { + expect(triangleArea(7, 4)).toEqual(14); + }); +}); diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..b8dc6c9 --- /dev/null +++ b/src/index.js @@ -0,0 +1,5 @@ +const triangleArea = (base, height) => { + return (base * height) / 2 +}; + +module.exports = triangleArea; \ No newline at end of file