Skip to content

Instantly share code, notes, and snippets.

View fdjones's full-sized avatar

Freddie fdjones

View GitHub Profile
function isDivisibleByY(n, y) {
return n % y === 0; // returns true or false
}
function createNewArray(n) {
return Array.from(Array(n).keys()).map(i => ++i)
}
function print(string) {
console.log(string);
for(var i = 1; i < 101; i++) {
if(i % 3 === 0 && i % 5 === 0) {
console.log('Fizz Buzz');
}
if(i % 5 === 0) {
console.log('Fizz');
}
if(i % 3 === 0) {
console.log('Buzz')
}
// 1: just returns undefined
function isEven(num) {
if(num === 0) {
return true;
}
else if(num === 1) {
return false;
}
else {
function foo() {
return {
input: this.input,
delimiter: this.delimier,
push: function(newString) {
this.input = this.input ? this.input + this.delimiter + newString : newString;
},
pop: function() {
const LAST_INDEX = this.input.lastIndexOf(this.delimiter);
this.input = (LAST_INDEX !== -1) ? this.input.substring(0, LAST_INDEX) : '';
function foo(arg1, arg2) {
return {
input: arg1,
delimiter: arg2,
push: function (newString) {
this.input = this.input ? this.input + this.delimiter + newString : newString;
},
pop: function () {
const LAST_INDEX = this.input.lastIndexOf(this.delimiter);
this.input = (LAST_INDEX !== -1) ? this.input.substring(0, LAST_INDEX) : '';
// class
class foo {
constructor(a, b) {
this.a = a;
this.b = b;
}
bar() {
return true;
<div class="foo"
id="bar"
data-info="foobar"
aria-hidden="true"
role="button">
</div>
import checkIfArray from './checkIfArray';
function checkIfString(x) {
x.forEach(function(el) {
if (typeof el !== 'string') {
throw new Error('Array can only contain strings');
}
});
}
{
"parser": "babel-eslint",
"extends": "plugin:flowtype/recommended",
"plugins": ["eslint-plugin-flowtype"],
"settings": {
"flowtype": {
"onlyFilesWithFlowAnnotation": true
}
},
"env": {
// @flow
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
type Props = {
name: string,
age: number,
DOB: number,