Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Calculating with Functions

function ex(x,value) {
    return typeof x === 'function' ? x(value) : value

}
 
function zero(x) {
    const value = 0

    return ex(x,value)
}
function one(x) {
    const value = 1

    return ex(x,value)
}

function two(x) {
    const value = 2

    return ex(x,value)
}

function three(x) {
    const value = 3

    return ex(x,value)
}
function four(x) {
    const value = 4

    return ex(x,value)

}
function five(x) {
    const value = 5

    return ex(x,value)
}
function six(x) {
    const value = 6

    return ex(x,value)
}
function seven(x) {

    const value = 7

    return ex(x,value)

}
function eight(x) {
    const value = 8

    return ex(x,value)
}
function nine(x) {
    const value = 9

    return ex(x,value)
}

function plus(x) {
    return (y) => {
        return x + y
    }

}
function minus(x) {
    return (y) => {

      return y-x
    }


}
function times(x) {
    return (y) => {
       return x * y
    }


}
function dividedBy(x) { 
    return (y)=>{
      return Math.floor(y/x)
    }
}

console.log(two(dividedBy(six())))



 
PREVIOUS NEXT
Tagged: #Calculating #Functions
ADD COMMENT
Topic
Name
6+4 =