From 4c9fab80253adc15afeef4607532c4839c2a11c6 Mon Sep 17 00:00:00 2001 From: Roshan Kumar <58213083+Roshaen@users.noreply.github.com> Date: Thu, 28 Jan 2021 01:36:56 +0530 Subject: [PATCH] Added selection sort algorithm in javascript (#33) --- sorting/js/selection-sort.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 sorting/js/selection-sort.js diff --git a/sorting/js/selection-sort.js b/sorting/js/selection-sort.js new file mode 100644 index 00000000..69f312b2 --- /dev/null +++ b/sorting/js/selection-sort.js @@ -0,0 +1,15 @@ +let sort = [12,6,3,88,1,4,8] + +for(let i=0; isort[i]){ + //swaping elements + let temp = sort[i]; + sort[i]=sort[j]; + sort[j]= temp; + } + } +} + +console.log(sort) \ No newline at end of file