strings.repeat() function

The strings.repeat() function returns a string consisting of i copies of a specified string.

*Output data type: String*

  1. import "strings"
  2. strings.repeat(v: "ha", i: 3)
  3. // returns "hahaha"

Parameters

v

The string value to repeat.

*Data type: String*

i

The number of times to repeat v.

*Data type: Integer*

Examples

Repeat a string based on existing columns
  1. import "strings"
  2. data
  3. |> map(fn: (r) => ({
  4. laugh: r.laugh
  5. intensity: r.intensity
  6. laughter: strings.repeat(v: r.laugh, i: r.intensity)
  7. })
  8. )