JSFiddle - React, Tailwind, and code Playground

Integer addition

by tonytlwu

JavaScript

function addOne(i) {
	// i is an array of single digit integers
  // The arry of integers represent an integer, e.g. [5, 1, 2] represents 512 in base 10
  // Add 1 to the represented integer and return the result as an array in the same format as i
  // e.g.
  //   [5, 1, 2] => [5, 1, 3]
  //   [2, 9, 9] => [3, 0, 0]
  //   [-3, -2] => [-3, -1]
  //
  // BONUS: Implement this for a different base? (e.g. Base 2 - binary)
}