Skip to content
This repository was archived by the owner on Oct 26, 2020. It is now read-only.

Hiba's homework WK1 (Mandatory+Extra) #3

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Done Extra piping
  • Loading branch information
Hiba-moh committed Jun 14, 2020
commit 34b3b02d35004a0894f6ef08a2b9ff07b6aa13dd
20 changes: 12 additions & 8 deletions week-1/3-extra/2-piping.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,30 @@
the final result to the variable goodCode
*/

function add() {

function add(a,b) {
let c=a+b
return parseFloat(c.toFixed(1))
}

function multiply() {

function multiply(a,b) {
return(a*b)
}

function format() {

function format(price) {
return("£"+price)
}

const startingValue = 2

// Why can this code be seen as bad practice? Comment your answer.
let badCode =
let badCode = format(2*(add(startingValue,10)))

/* BETTER PRACTICE */
let sum=add(startingValue,10)
let mul=multiply(sum,2)
let form=format(mul)

let goodCode =
let goodCode = form

/* ======= TESTS - DO NOT MODIFY =====
There are some Tests in this file that will help you work out if your code is working.
Expand Down