Skip to content

Instantly share code, notes, and snippets.

@sergiandreplace
Created January 11, 2020 12:58
Show Gist options
  • Save sergiandreplace/991dfdd8629dd3a0e8d4d10b1c1f5cdf to your computer and use it in GitHub Desktop.
Save sergiandreplace/991dfdd8629dd3a0e8d4d10b1c1f5cdf to your computer and use it in GitHub Desktop.
var a = Math.cos(Math.sin(((4 + 3) * 3)))
const PI = 3.14159
const GRAVITY = 9.8
// function concatenate(array) {
// let a = ""
// for (let i = 0; i < array.length; i++) {
// const element=array[i]
// a += element
// }
// return a
// }
// function sum(a,b) {
// return a+b
// }
// let sumFunction=function(a,b) {
// return a+b
// }
// let arrowSum = (a,b) => { return a+b }
// (a,b) => a+b;
// (a,b) => console.log(a)
// console.log(b)
// return a+b
function onMyButtonClick() {
//... do things
}
// myButton.addEventListener("click", onMyButtonClick)
// let action = "click"
// myButton.addEventListener(action, setButtonRed);
function sumUpToFourNumbers(a,b=0,c=0,d=0) {
return a +b +c+ d;
}
module.exports = sumUpToFourNumbers;
var sumUpToFourNumbers=require('./index.js')
test("Testing template literals", ()=> {
let person = {"name": "Ana", "address":"Elm St.", "city":"Gotham"}
console.log("Hello " + person.name + " from " + person.address + " in " + person.city)
console.log(`Hello ${person.name}\nfrom ${person.address}\nin ${person.city}`)
})
test("Default parameters",()=> {
//given
let firstNumber = 1
//when
let result=sumUpToFourNumbers(firstNumber)
//then
expect(result).toBe(firstNumber)
})
test("Default parameters 2",()=> {
//given
let firstNumber = 15
let secondNumber = 89
let expected = 104
//when
let result=sumUpToFourNumbers(firstNumber, secondNumber)
//then
expect(result).toBe(expected)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment