Nodejs Utililty Methods Array Bubble Sort

List of utility methods to do Array Bubble Sort

Description

The list of methods to do Array Bubble Sort are organized into topic(s).

Method

bubbleSort()
Array.prototype.bubbleSort = function () {
  let flag = false;
  while (flag === false) {
    flag = true;
    let i = 0;
    for (let j = i + 1; j < this.length; j++) {
      if (this[i] > this[j]) {
        flag = false;
        let holder = this[i];
...
bubbleSort()
Array.prototype.bubbleSort = function() {
  let sorted = false;
  while (!sorted){
    sorted = true;
    for (let i = 0; i < this.length - 1; i++) {
      let j = i + 1;
      if (this[i] > this[j]) {
        sorted = false;
        [this[i], this[j]] = [this[j], this[i]];
...
bubbleSort()
"use strict";
Array.prototype.bubbleSort = function () {
  let isSorted = false;
  while (!isSorted) {
    isSorted = true;
    for (let i = 0; i < (this.length - 1); i++) {
      if (this[i] > this[i + 1]) {
        let tmp = this[i];
        this[i] = this[i + 1];
...
bubbleSort()
Array.prototype.bubbleSort = function () {
  var unsorted = true;
  while (unsorted) {
    unsorted = false;
    for ( var i = 0; i < this.length - 1; i++ ) {
      if ( this[i] > this[i+1] ) {
        var placeholder = this[i];
        this[i] = this[i+1];
        this[i+1] = placeholder;
...
bubbleSort()
Array.prototype.bubbleSort = function () {
  let isSorted = false;
  while (!isSorted) {
    isSorted = true;
    for (let i = 0; i < (this.length - 1); i++) {
      if (this[i] > this[i + 1]) {
        [this[i], this[i + 1]] = [this[i + 1], this[i]];
        isSorted = false;
  return this;
};
console.log([5, 3, 4, 2, 1].bubbleSort());
String.prototype.substrings = function () {
  let substrings = [];
  for (let start = 0; start < this.length; start++) {
    for (let len = 1; (start + len) <= this.length; len++) {
      substrings.push(this.substring(start, start + len));
  return substrings;
};
console.log("abc".substrings());
bubbleSort()
Array.prototype.bubbleSort = function () {
  var unsorted = true;
  while (unsorted) {
    unsorted = false;
    for (i = 0; i < this.length - 1; i++) {
      if (this[i] > this[i + 1]) {
        var temp = this[i];
        this[i] = this[i + 1];
        this[i + 1] = temp;
...
bubbleSort()
Array.prototype.bubbleSort = function() {
  var secondArray = this.slice(0);
  for(var j = 0; j <= secondArray.length; j++) {
    for(var i = 0; i < secondArray.length-1; i++) {
      var first_el = secondArray[i];
      var second_el = secondArray[i+1];
      if(first_el > second_el) {
        secondArray[i] = second_el;
        secondArray[i+1] = first_el;
...
bubbleSort()
function factors(num) {
  for(let i=0; i <=num; i++ ) {
    if (num % i === 0) {
      console.log(i);
Array.prototype.bubbleSort = function () {
  let sorted = false;
...
bubbleSort()
var fibonacci = function(num) {
  var fibs = [0, 1];
  if (num < 3) {
    return fibs.slice(0, num);
  while (fibs.length < num) {
    fibs.push(fibs[fibs.length - 1] + fibs[fibs.length - 2]);
  return fibs;
...
bubbleSort()
Array.prototype.bubbleSort = function() {
  var temp;
  for(var i = 0; i < this.length - 1; i++) {
    for(var z = 0; z <= this.length - i - 1; z++) {
      if(this[z] > this[z + 1]) {
        temp = this[z + 1];
        this[z + 1] = this[z];
        this[z] = temp;
  return this;
var a = [23,34,55,24,51,56,27,29];
a.bubbleSort();
console.log(a);