multiply string js code example

Example 1: javascript multiline string

const multilineString = `This
is
a
multiline
string
in
javascript`;

Example 2: js multiply string

let myString = 'test';

myString.repeat(3);		// 'testtesttest'

Example 3: js string times

let string = 'Plumbus'
let count = 3

string.repeat(count); // -> 'PlumbusPlumbusPlumbus'

Example 4: javascript multiline string

// OPTION 1
var MultilineString = `This
is 
a multiline 
string`; // Note: use the template quotation marks above the tab key

// OPTION 2
var MultilineString = 'This \n\
is \n\
a multiline \n\
string'; // Note: use the "\n\" as a newline character

Example 5: how to repeat a string in javascript

function repeatStringNumTimes(string, times) {
  var repeatedString = "";
  while (times > 0) {
    repeatedString += string;
    times--;
  }
  return repeatedString;
}
repeatStringNumTimes("abc", 3);

Example 6: repeat js

repeatStr = (n, s) => s.repeat(n);