Skip to content

Instantly share code, notes, and snippets.

View rphansen91's full-sized avatar

Ryan Hansen rphansen91

  • Antengo
  • San Diego
View GitHub Profile

Make Consecutive Array

Given the following array, [6, 2, 3, 8] find the minimum number of entries needed to make the array consecutive

[2, 3, *4*, *5*, 6, *7*, 8] = 3 entries needed. 

Test cases

makeConsecutive([0, 2]) === 2
@rphansen91
rphansen91 / App.js
Last active November 4, 2018 01:48
React redux connect implementation using react hooks.
import React from 'react';
import useStore from './useStore';
import Todo from './Todo'
import { todoActions } from './actions';
export default () => {
const [
todos,
{ addTodo, rmTodo }
] = useStore(store => store.todos, todoActions)
@rphansen91
rphansen91 / index.js
Last active December 14, 2016 18:25
React From Scratch in ~100 lines
import Component from './toy-react'
import { div, img } from './toy-jsx'
class Nested extends Component {
render () {
const { src, style } = this.props;
return img({ src, style })
}
}