diff --git a/Untitled-1.js b/Untitled-1.js new file mode 100644 index 0000000..65372a9 --- /dev/null +++ b/Untitled-1.js @@ -0,0 +1,33 @@ +// we covered .map .filter and foreach +//const forEacReturnValue= arrayOfFellowws.forEach( eachFel +> console.log(" check" + eachFel.name)) + +const checkFellowName = (eachFel) => { + console.log(" check" + eachFel.name) +} + +//console.log(checkFellowName) +//arraoOfFellows.forEach(checkFellowName) + + +// arrayofFellows.forEach( checkFellowName ) +//arrayOfFellows.forEach(checkFellowName()) +arrayOfFellows.forEach( () => checkFellowName () ) + +// structure an anonymous function and use it in a dynamic way . +//filtering process on an array of objects + +const arrayOfFellows = [ + {name: "PersonA"}, + {name: "PersonAB"}, + {name: "PersonABC"}, + {name: "PersonABCD"}, + {name: "PersonABCDE"} +] +const FilteredArrayOfFellow = [] + +for(const eachFell of arrayOfFellows) { + if(eachFell.name.length> 5){ + FilteredArrayOfFellow.push(eachFell) + } +} +console.log(FilteredArrayOfFellow) \ No newline at end of file diff --git a/index.js b/index.js index 3bb4d07..8d5ce43 100644 --- a/index.js +++ b/index.js @@ -4,7 +4,33 @@ * Depending on the operation, either add up all of the numbers or subtract all of the numbers, from left to right. * @returns {number} The result of either adding all numbers or subtracting all numbers, depending on the arguments added to the command line. */ -function calculator() {} +function calculator( ) { +const thisACalc = (something,a,b,c) =>{ + const calculator = something(a,b,c); + console.log(add); +}; + +if(something === "plus") { +const plus = (a,b,c) => { + return a + b + c; +}; + +} else if (something === "minus") { + const minus = (a,b,c) => { + return a - b - c; + }; + +}else if (something === "divide") { + return "Invalid operation: diivide"; + }; + +}else if (something === " ") { + return "No numbers provided"; + }; + if (something !== "something") { + return " No operation provided"; + }; + // Don't change anything below this line. module.exports = calculator; diff --git a/readme.md b/readme.md index 2ae3fca..31789e7 100644 --- a/readme.md +++ b/readme.md @@ -149,5 +149,5 @@ node index.js ## Tips - Remember that the first and second elements of `process.argv` are always the path to the `node` program and the filepath. -- Remember that each argument from the command line will be read in as a string. You will need some way to convert the inputs from strings to numbers. +- Remember that each argument from the command line will be read in as a string. You will need some way to con10vert the inputs from strings to numbers. - Because you don't know how many numbers will be passed in, you may need to _iterate_ over the numbers.