“Rejoignez Array JS” Réponses codées

Rejoignez Array JS

const elements = ['Sun', 'Earth', 'Moon'];

console.log(elements.join());
// output: "Sun,Earth,Moon"

console.log(elements.join(''));
// output: "SunEarthMoon"

console.log(elements.join('-'));
// output: "Sun-Earth-Moon"
Batman

JS JOIN

//turns array to string

const elements = ['Fire', 'Air', 'Water'];

console.log(elements.join());
// expected output: "Fire,Air,Water"

console.log(elements.join(''));
// expected output: "FireAirWater"

console.log(elements.join('-'));
// expected output: "Fire-Air-Water"
mikelikestocode

JS Join Array

let array = [0, 1, 2, 3, 4, 5];
/*
Array.prototype.join(separator);
Returns a string version of the array with
the input separator between each element.
*/
var string = array.join("");
console.log(string); // -> 012345
MattDESTROYER

se joindre à JavaScript

/* split methods splits string object into array of strings  
and join method changes element of array into a string */
const name= "Shirshak Kandel"
const nameWithDash=name.split(" ").join("-")
console.log(nameWithDash);//Shirshak-kandel
Sab Tech

JS JOIN


const elements = ['Fire', 'Air', 'Water'];

console.log(elements.join());
// expected output: "Fire,Air,Water"

console.log(elements.join(''));
// expected output: "FireAirWater"

console.log(elements.join('-'));
// expected output: "Fire-Air-Water"
Impossible Iguana

se joindre à la table

var a = ['Wind', 'Water', 'Fire'];
a.join();      // 'Wind,Water,Fire'
a.join(', ');  // 'Wind, Water, Fire'
a.join(' + '); // 'Wind + Water + Fire'
a.join('');    // 'WindWaterFire'
kepl3r

Réponses similaires à “Rejoignez Array JS”

Questions similaires à “Rejoignez Array JS”

Plus de réponses similaires à “Rejoignez Array JS” dans JavaScript

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code