tanaris-js - v0.0.1-alpha.5
    Preparing search index...

    Function intersperse

    • Returns a new array containing all the elements from array, but withElement in between each one.

      Parameters

      • array: any[]
      • withElement: any

      Returns any[]

      import { intersperse } from "tanaris/arrays";

      const nums = [1, 2, 3];
      const interspersed = intersperse(nums, ", ");
      const prettyStr = interspersed.reduce((acc, e) => acc + e, "");

      console.log(interspersed); //=> [1, ", ", 2, ", ", 3]
      console.log(prettyStr); //=> "1, 2, 3"