Skip to content

Instantly share code, notes, and snippets.

View OlivierJM's full-sized avatar

ojm OlivierJM

View GitHub Profile
// cheap fix
function calculateAge(bornYear, currentYear){
if(bornYear !== undefined && currentYear !== undefined){
console.log(currentYear - bornYear);
} else {
console.log("provide both year values")
}
}
calculateAge(2000, 2018); // 18
function calculateAge(bornYear, currentYear){
console.log(currentYear - bornYear);
}
calculateAge(2000, 2018); // 18
calculateAge() // NAN
const name = "Johnaas"
const age = 35;
const city = "lusaka";
const message = `my name is ${name} am ${age} years old and I live in ${city}`
console.log(message); // "my name is Johnaas am 35 years old and I live in lusaka"
const name = "Johnaas"
const age = 35;
const city = "lusaka";
const message = "my name is "+ name + ", am " + age + "years old and I live in " + city;
console.log(message); // "my name is Johnaas, am 35years old and I live in lusaka"
const person = {
name: "Johnaas",
job:"dev",
siblings: 2,
friends: "loading ..",
};
const { name, ...obj } = person;
console.log(name); // Johnaas
console.log(obj);
/*
const items = [1, 2, 3, 4, 5 ];
if(items.includes(5)){
console.log(true) // true
}
if(items.indexOf(5) > -1){
console.log(true); // true ;
}
@OlivierJM
OlivierJM / HOC.js
Created July 19, 2018 09:38 — forked from Restuta/HOC.js
React HOC (Higher Order Component) Example
/* HOC fundamentally is just a function that accepts a Component and returns a Component:
(component) => {return componentOnSteroids; } or just component => componentOnSteroids;
Let's assume we want to wrap our components in another component that is used for debugging purposes,
it just wraps them in a DIV with "debug class on it".
Below ComponentToDebug is a React component.
*/
//HOC using Class
//it's a function that accepts ComponentToDebug and implicitly returns a Class
let DebugComponent = ComponentToDebug => class extends Component {
@OlivierJM
OlivierJM / gist:2d096363f93f8d2097f0e47c2dff126b
Created April 23, 2018 06:26 — forked from stewartduffy/gist:481f21ea4906e611d934
Regex to remove file extension from JS string.
var filenameFull = "tm_icons.png";
//Regex to remove
var filenameText = filenameFull.replace(/\.[^/.]+$/, "");
@OlivierJM
OlivierJM / advanced-web.md
Last active April 11, 2022 05:32
Syllabus

New ES6 Features
React
MongoDB
Meteor

This will take 5 weeks ⇒ 1month + 1 week

New ES6 Features (Half a week)

  • Re-Introduction to Programming Languages
  • What is ES6
  • Classes
@OlivierJM
OlivierJM / Syllabus.md
Created March 27, 2018 14:48
Syllabus

New ES6 Features
React
MongoDB
Meteor

This will take 5 weeks ⇒ 1month + 1 week

New ES6 Features

  • Re-Introduction to Programming Languages
  • What is ES6
  • Classes