mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-17 00:16:04 +09:00
wp: text justification wip
This commit is contained in:
@@ -334,6 +334,25 @@ Array.prototype.tail = function() {
|
||||
Array.prototype.init = function() {
|
||||
return this.slice(0, this.length - 1)
|
||||
}
|
||||
Array.prototype.shuffle = function() {
|
||||
let counter = this.length;
|
||||
|
||||
// While there are elements in the array
|
||||
while (counter > 0) {
|
||||
// Pick a random index
|
||||
let index = Math.floor(Math.random() * counter);
|
||||
|
||||
// Decrease counter by 1
|
||||
counter--;
|
||||
|
||||
// And swap the last element with it
|
||||
let temp = this[counter];
|
||||
this[counter] = this[index];
|
||||
this[index] = temp;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// NOTE TO PROGRAMMERS: this JS_INIT script does not, and must not be invoked with strict mode //
|
||||
|
||||
Reference in New Issue
Block a user