Skip to content

Instantly share code, notes, and snippets.

View geni429's full-sized avatar

Roy Jeong geni429

View GitHub Profile
// jest
const sum = require('<module_path>/sum');
test('Add 1 and 2', () => {
expect(sum(1, 2)).toBe(3);
});
@geni429
geni429 / sum.js
Last active January 24, 2019 08:38
const sum = function sumInteger(num1, num2) {
const sumIntegerResult = num1 + num2;
return sumIntegerResult;
}
const arr = [1, 2, 3];
let foo;
foo = arr.map(function(ele) {
return ele + 1;
});
foo = arr.map(ele => ele + 1);
@geni429
geni429 / .js
Created August 7, 2018 09:40
Simple calculate(sum) code
// function
function sum_func(a, b) {
return a + b;
}
// arrow function
const sum_arrow = (a, b) => a + b;
function foo() {
this.x = 1;
this.y = 2;
}
foo.prototype = {
bar: function() {
function add() {
return this.x + this.y;
}
@geni429
geni429 / .js
Last active August 7, 2018 09:18
function foo() {
this.x = 1;
this.y = 2;
}
foo.prototype = {
bar: function() {
const add = () => this.x + this.y;
return add();
@geni429
geni429 / .js
Last active August 7, 2018 09:18
function foo() {
this.x = 1;
this.y = 2;
}
foo.prototype = {
bar: function() {
function add() {
return this.x + this.y;
}
@geni429
geni429 / .jsx
Last active August 7, 2018 08:41
import React, { Component, Fragment } from 'react';
class Foo extends Component {
constructor() {
super();
this.state = {
num: 0
}
this.add = this.add.bind(this);
}
@geni429
geni429 / .js
Created August 7, 2018 07:21
JavaScript function example(1)
function foo() {
return 'Hello World!';
}