Skip to content

Instantly share code, notes, and snippets.

View zurivy-myval's full-sized avatar

Marek Kaštil zurivy-myval

View GitHub Profile
@stefanmaric
stefanmaric / toBase.js
Created April 1, 2019 14:16
Get a string represnetation of an integer in any base
/**
* Transform a number to any base based on a provided range.
* TODO: doesn't support floats.
* @param {number} baseTen A regular, primitive integer number
* @param {Array<string>} range And array of characters to represent the positional system.
* @returns {string} A representation of the provided number in the positional system provided.
*/
const toBase = (baseTen, range = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('')) => {
if (baseTen % 1 > 0) throw new TypeError('Only integers are supported')
if (baseTen === 0) return range[0]
@ericelliott
ericelliott / essential-javascript-links.md
Last active July 18, 2024 15:03
Essential JavaScript Links