npx standard --fix

This commit is contained in:
cclauss
2020-05-03 09:05:12 +02:00
parent e62ad2f73e
commit 856dc2f63c
47 changed files with 2240 additions and 2371 deletions

View File

@ -5,22 +5,22 @@
*/
Array.prototype.wiggleSort = function () {
for (let i = 0; i < this.length; ++i) {
const shouldNotBeLessThan = i % 2;
const isLessThan = this[i] < this[i + 1];
if (shouldNotBeLessThan && isLessThan) {
[this[i], this[i + 1]] = [this[i + 1], this[i]];
}
for (let i = 0; i < this.length; ++i) {
const shouldNotBeLessThan = i % 2
const isLessThan = this[i] < this[i + 1]
if (shouldNotBeLessThan && isLessThan) {
[this[i], this[i + 1]] = [this[i + 1], this[i]]
}
return this;
};
}
return this
}
//Implementation of wiggle sort
// Implementation of wiggle sort
var arr = [3, 5, 2, 1, 6, 4];
//Array before Wiggle Sort
console.log(arr); //[3, 5, 2, 1, 6, 4]
var arr = [3, 5, 2, 1, 6, 4]
// Array before Wiggle Sort
console.log(arr) // [3, 5, 2, 1, 6, 4]
arr.wiggleSort()
//Array after wiggle sort
console.log(arr); // [ 3, 5, 2, 6, 1, 4 ]
// Array after wiggle sort
console.log(arr) // [ 3, 5, 2, 6, 1, 4 ]