Skip to content

Instantly share code, notes, and snippets.

View djD-REK's full-sized avatar
🌞
Full-Stack JavaScript Developer & Doctor of Physical Therapy 🌞

Dr. Derek Austin djD-REK

🌞
Full-Stack JavaScript Developer & Doctor of Physical Therapy 🌞
View GitHub Profile
const wittyAI = 'I am \'not\' sentient.'
const wittyReply = 'No, you\'re definitely not "sentient."'
console.log(wittyAI,wittyReply)
const getEmail = username => `${username}@gmail.com`
function getUser (username) {
const email = getEmail(username)
return {
username: username,
email: email
}
}
console.log(getUser("MrRoboto")) // Object { username: "MrRoboto", email: "[email protected]" }
const getEmail = username => `${username}@gmail.com`
function getUser (username) {
const email = getEmail(username)
return {
username,
email
}
}
console.log(getUser("MrRoboto")) // Object { username: "MrRoboto", email: "[email protected]" }
const hello = { world: function() {
console.log('Hello World!')
}}
hello.world() // Hello World!
const helloAgain = { world() {
console.log('Hello World!')
}}
helloAgain.world() // Hello World!
const actions = {
step: 0,
printCount() {
console.log(this.step)
},
takeStep() {
this.step++
}
}
actions.takeStep()
const actions = {
step: 0,
printCount: function () {
console.log(this.step)
},
takeStep: function () {
this.step++
}
}
actions.takeStep()
[name, age, gender] = ["Derek","30","Male"]
const wordyObject = {
name: name,
age: age,
gender: gender
}
const conciseObject = {
name,
age,
gender
console.log(cheese) // ReferenceError: can't access lexical declaration `cheese' before initialization
let cheese = "Gouda"
let [profit, costs] = [120000, 100000] // It was a good month
// Employee bonus structure: $1000 if >10% profit, $100 if not
let employeeBonus = (profit/costs > 1.10) ? 1000 : 100
console.log("$"+employeeBonus) // $1000
employeeBonus = profit/costs > 1.10 ? 1000 : 100