Skip to content

Instantly share code, notes, and snippets.

View krzysztofczernek's full-sized avatar

Krzysztof Czernek krzysztofczernek

View GitHub Profile
function add (x, y) {
return x + y
}
function coin () {
return Math.random() < 0.5 ? 'heads' : 'tails'
}
let firstName = 'krzysztof'
function uppercaseName (lastName) {
return `${firstName.toUpperCase()} ${lastName.toUpperCase()}`
}
let user = {
firstName: 'Krzysztof',
age: '26'
}
function happyBirthday () {
user.age = user.age + 1
}
function calculatePrice (unitPrice, noOfUnits, couponValue = 0) {
return unitPrice * noOfUnits - couponValue;
}
function add (a, b) {
return a + b
}
function multiply (a, b) {
return a * b
}
const operations = { // here we're using add and multiply as regular values
add,
const numbers = [1, 1, 2, 3, 5, 8]
const transformFunction = x => x + 2
numbers.map(transformFunction)
function makeGreeter (greeting) {
return function greet (name) {
return `${greeting}, ${name}!`
}
}
// or, using the ES6 syntax:
const makeGreeter = greeting => name => `${greeting}, ${name}!`

Keybase proof

I hereby claim:

To claim this, I am signing this object:

let firstName = 'krzysztof'
function uppercaseName (lastName) {
return `${firstName.toUpperCase()} ${lastName.toUpperCase()}`
}
console.log(uppercaseName('doe')) // Prints "KRZYSZTOF DOE"
// Lots and lots of code...