From d6601c3326775914179e159ccbb4460de0671854 Mon Sep 17 00:00:00 2001 From: Tyson Hood Date: Wed, 28 Oct 2020 14:44:10 -0700 Subject: [PATCH 1/3] Add bubbleSort() in JavaScript --- day31/JavaScript/bubblesort.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/day31/JavaScript/bubblesort.js b/day31/JavaScript/bubblesort.js index e69de29b..71abecec 100644 --- a/day31/JavaScript/bubblesort.js +++ b/day31/JavaScript/bubblesort.js @@ -0,0 +1,13 @@ +let bubbleSort = (arr) => { + for(i = 0; i < arr.length; i++) { + for(j = 0; j < arr.length; j++) { + if (arr[j] > arr[j+1]) { + arr.splice(j+2, 0, arr[j]) + arr.splice(j, 1) + } + } + } + return arr; +} + +bubbleSort([1, 8, 3, 2, 9, 5, 4]) \ No newline at end of file From 5afeac48bdbbe37d9ef0fd844dd228782131c9c8 Mon Sep 17 00:00:00 2001 From: Tyson Hood Date: Wed, 28 Oct 2020 15:10:46 -0700 Subject: [PATCH 2/3] Add JavaScript code for Day 31 - Bubble Sort --- .all-contributorsrc | 11 +++++++++++ day31/JavaScript/bubblesort.js | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 4342ac5d..23bee1c2 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -329,6 +329,17 @@ "code" ] } + ], + { + "login": "RrennM", + "name": "RrennM", + "avatar_url": "https://avatars2.githubusercontent.com/u/27599411?s=400&u=773dbb8a4f877cf06770cbd39e4ddeeafeedcbdd&v=4", + "profile": "https://github.com/RrennM", + "contributions": [ + "doc", + "code" + ] + } ], "commitConvention": "none" } diff --git a/day31/JavaScript/bubblesort.js b/day31/JavaScript/bubblesort.js index 71abecec..eefb5688 100644 --- a/day31/JavaScript/bubblesort.js +++ b/day31/JavaScript/bubblesort.js @@ -1,3 +1,8 @@ +/** + * @author: RrennM + * @date: Oct 28, 2020 +**/ + let bubbleSort = (arr) => { for(i = 0; i < arr.length; i++) { for(j = 0; j < arr.length; j++) { From 6db1c36028cf5364a139f1b60fddc239d58a195a Mon Sep 17 00:00:00 2001 From: Aadit Kamat Date: Sat, 31 Oct 2020 21:55:38 +0800 Subject: [PATCH 3/3] Update .all-contributorsrc --- .all-contributorsrc | 1 - 1 file changed, 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 23bee1c2..0b314087 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -336,7 +336,6 @@ "avatar_url": "https://avatars2.githubusercontent.com/u/27599411?s=400&u=773dbb8a4f877cf06770cbd39e4ddeeafeedcbdd&v=4", "profile": "https://github.com/RrennM", "contributions": [ - "doc", "code" ] }