My Profile Photo

Keyduq


Full stack developer, javascript lover, also php and java (Android) developer


Welcome to my blog

This is my first post in this blog, just wanna try this…

sudo npm i -g express

This is a basic sorting algorithm in javascript

function sort() {
  const data = this;
  for(let i = 0; i <= data.length; i++) {
    for(let j = 0; j <= data.length - i; j++) {
      if (data[j] > data[j+1]) {
        const temp = data[j]
        data[j] = data[j+1]
        data[j+1] = temp
      }
    }
  }
  return data
}

Array.prototype.sort = sort

const datos = [5,8,15,24,54,1,3,0,101,49]

console.log(datos.sort())
comments powered by Disqus