2-min Bubble Sort(of pointless?) — Algorithm Basics —

A Bubble. It moves up?
function swap(arr, index1, index2){}
function swap(arr, index1, index2){
[arr[index1], arr[index2]] = [arr[index2],arr[index1]
Party Time, we are almost there!
function bubbleSort(arr){
//we are going to set out i value to the array.length so that we are
//not going over the full length of the array every iteration.

for(let i = arr.length; i>0;i--){
for(let j = 0; j<i; j++){

//if the current index is greater than the next index, we Swap //<strong/>
if(arr[j]> arr[j+1]){
swap(arr, j, j+1);




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Kafka CLI — Commands

Heroku Explained

My Hyper/OhMyZsh config

WhatsApp Online Status Tracker

Polkadot XCM format goes live and enables NFT functionalities

Ethererum POA (Clique) on Kubernetes — Part 2

Tiling window manager under X11: i3

Insiders Secret To Cracking the Google Summer Of Code — Part 1

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Anthony Johnson

Anthony Johnson

More from Medium

What is 𝗻𝘃𝗺 ❓️ — ⓝⓥⓜ 𝟭𝟬𝟭 in 5 minutes !

Image showing that how nvm — node version manager,  manages multiple versions of node or nodeJS

How to Create a Linked List in JavaScript

Deep Dive into Data structures using Javascript — Stack

How to convert strings into an array of characters.