From d9148450fedccb948a21d77dfef6644a527ffd8d Mon Sep 17 00:00:00 2001 From: Marlon Gomez Date: Thu, 17 Nov 2022 00:28:25 +0000 Subject: [PATCH 1/2] tiny refactor --- .devcontainer/devcontainer.json | 19 +++++++++++++++++ src/BadCode.js | 38 +++++++++++++++++++-------------- 2 files changed, 41 insertions(+), 16 deletions(-) create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..d8d2bd7 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,19 @@ +{ + "name": "react-table", + "image": "mcr.microsoft.com/devcontainers/javascript-node:18-bullseye", + + // Features to add to the dev container. More info: https://containers.dev/implementors/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "npm install" + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/src/BadCode.js b/src/BadCode.js index 087b4b9..3328add 100644 --- a/src/BadCode.js +++ b/src/BadCode.js @@ -1,31 +1,37 @@ import React from 'react' export default function BadCode() { - const function calcularCosito(x, y, z) { - // Toma el medio y lo multiplica para uqe retorne 4 veces su valor - var i=4*y; - // Suma el medio con los extremos alto y bajo para tener la suma de todos los valores a sumar - var j= x+i+y; - //Dividir entre 6 - var k = j/6 - return k; + // TODO: confirm names for domain + const testValues = { + expected: 50, + high: 70, + low: 45, + } + + const getProbability = (expected, high) => { + return (expected + (5 * high)) / 6; }; - const error = (X,Y) =>{ - return Math.sqrt(Math.pow((X-B), 2)/36); + const getErrorRate = (high, low) => { + return Math.sqrt(Math.pow((high-low), 2) / 36); }; - const analProb = (esperado, alto, bajo) => { - const prob = calcularCosito(alto, esperado, bajo); - const errorARetornarEnLaFuncion= error(alto, bajo); - return {prob, e} + const getProbabilityAndErrorRate = (expected, high, low) => { + const prob = getProbability(expected, high, low); + const err = getErrorRate(high, low); + return {prob, err} } - const render = analProb(50, 70, 45); + const render = getProbabilityAndErrorRate( + testValues.expected, + testValues.high, + testValues.low, + ); + return (

El esperado es {render.prob}

-

El error es {render.e}

+

El error es {render.err}

) } From 89b0cd4c516eb34202b230a0c60c2664440d3ee3 Mon Sep 17 00:00:00 2001 From: Marlon Gomez Date: Thu, 17 Nov 2022 00:30:58 +0000 Subject: [PATCH 2/2] delete .devcontainer directory --- .devcontainer/devcontainer.json | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index d8d2bd7..0000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "react-table", - "image": "mcr.microsoft.com/devcontainers/javascript-node:18-bullseye", - - // Features to add to the dev container. More info: https://containers.dev/implementors/features. - // "features": {}, - - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "npm install" - - // Configure tool-specific properties. - // "customizations": {}, - - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" -}