Skip to content

Instantly share code, notes, and snippets.

View itzjonas's full-sized avatar

Jason Seegmiller itzjonas

View GitHub Profile
@itzjonas
itzjonas / oneliners.js
Created May 14, 2019 18:41
Useful One-Liners (JavaScript)
// Remove any duplicates from an array of primitives
const unique = [...new Set(arr)];
// Sleep in async functions. Use: await sleep(2000)
const sleep = (ms) => (new Promise(resolve => setTimeout(resolve, ms)));
// Type this in your code to break chrome debugger in that line.
debugger;
// Just plain english.
import React from 'react';
import { render } from 'react-dom';
function sumOfPrimes(e) {
e.preventDefault();
const num = document.getElementById('num').value;
if(num > 100000) {
document.getElementById('answer').innerHTML = 'ERROR: exceeds CodeSandbox infinite loop failsafe.';
@itzjonas
itzjonas / StarTowerNew.js
Last active February 6, 2018 06:01
Code Challenge: 2018-01-30 - https://repl.it/@itzjonas/StarTower
const starTowerNew = levels => [...Array(levels)].map((v, i) => '*'.repeat(i * 2 + 1).padStart(i + levels).padEnd(levels * 2 - 1));
console.log(starTowerNew(20));
@itzjonas
itzjonas / SearchFind.html
Last active February 6, 2018 05:40
Code Challenge: 2018-01-26 - https://codepen.io/itzjonas/pen/yvJRMr
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Search &amp; Find</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body>
<div id="app" />
@itzjonas
itzjonas / LinkedList.js
Last active February 1, 2018 18:56
Code Challenge: 2018-02-01
class LinkedList {
constructor(...values) {
this.head = null;
this.length = 0;
this.add(...values);
}
/**
* Individually adds a new node to the head of the linked list.
*