p
function shuffle (word) {
const array = word.split('')
const last = array.splice(-1, 1)
const [first, ...middle] = array
return `${first}${middle.sort((a, b) => Math.random() - 0.5).join('')}${last}`
}
Size: a a a
p
function shuffle (word) {
const array = word.split('')
const last = array.splice(-1, 1)
const [first, ...middle] = array
return `${first}${middle.sort((a, b) => Math.random() - 0.5).join('')}${last}`
}
p
p
p
${names[0]} likes this
, ${names[0]} and ${names[1]} like this
, ${names[0]}, ${names[1]} and ${names[2]} like this
, ${names[0]}, ${names[1]} and ${names.length - 2} others like this
, t
p
t
t
const word = document.querySelector('input');
...
shuffle(input.value)
p
const word = document.querySelector('input');
...
shuffle(input.value)
t
t
p
p
p
function shuffle (word) {
const array = word.split('')
const last = array.splice(-1, 1)
const [first, ...middle] = array
return `${first}${middle.sort((a, b) => Math.random() - 0.5).join('')}${last}`
}
DE
RU
function shuffle (word) {
const array = word.split('')
const last = array.splice(-1, 1)
const [first, ...middle] = array
return `${first}${middle.sort((a, b) => Math.random() - 0.5).join('')}${last}`
}