From 24e2a1bb2b618643e9f60d78ac3d955f614b6b21 Mon Sep 17 00:00:00 2001 From: CD Sigma Date: Sat, 21 Jul 2018 22:33:20 -0700 Subject: [PATCH 1/4] Implementation Edit to Bubble Sort in Javascript - Added main() - bubbleSort() now returns the sorted array --- contents/bubble_sort/bubble_sort.md | 2 +- contents/bubble_sort/code/javascript/bubble.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/contents/bubble_sort/bubble_sort.md b/contents/bubble_sort/bubble_sort.md index fe7dff4de..cf188bef0 100644 --- a/contents/bubble_sort/bubble_sort.md +++ b/contents/bubble_sort/bubble_sort.md @@ -17,7 +17,7 @@ This means that we need to go through the vector $$\mathcal{O}(n^2)$$ times with {% sample lang="java" %} [import:2-12, lang:"java"](code/java/bubble.java) {% sample lang="js" %} -[import:1-11, lang:"javascript"](code/javascript/bubble.js) +[import:1-12, lang:"javascript"](code/javascript/bubble.js) {% sample lang="py" %} [import:4-9, lang:"python"](code/python/bubblesort.py) {% sample lang="m" %} diff --git a/contents/bubble_sort/code/javascript/bubble.js b/contents/bubble_sort/code/javascript/bubble.js index fd97585ee..2e2102316 100644 --- a/contents/bubble_sort/code/javascript/bubble.js +++ b/contents/bubble_sort/code/javascript/bubble.js @@ -8,4 +8,12 @@ function bubbleSort(arr) { } } } + return arr; } + +function main() { + var testArray = [4,5,123,759,-132,8940,24,34,-5] + print(bubbleSort(testArray)); +} + +main(); From d83128772cc0affe208e0f6508e443843908b64a Mon Sep 17 00:00:00 2001 From: CD Sigma Date: Sun, 22 Jul 2018 11:59:04 -0700 Subject: [PATCH 2/4] Javascript fixes --- contents/bubble_sort/code/javascript/bubble.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contents/bubble_sort/code/javascript/bubble.js b/contents/bubble_sort/code/javascript/bubble.js index 2e2102316..291e2a4e6 100644 --- a/contents/bubble_sort/code/javascript/bubble.js +++ b/contents/bubble_sort/code/javascript/bubble.js @@ -8,12 +8,12 @@ function bubbleSort(arr) { } } } - return arr; } function main() { - var testArray = [4,5,123,759,-132,8940,24,34,-5] - print(bubbleSort(testArray)); + let testArray = [4, 5, 123, 759, -132, 8940, 24, 34, -5]; + bubbleSort(testArray); + console.log(testArray); } main(); From c910a5bc7621c40aa1ca3dcff3b37ccf545d717f Mon Sep 17 00:00:00 2001 From: CD Sigma Date: Sun, 22 Jul 2018 12:00:51 -0700 Subject: [PATCH 3/4] .md fixes --- contents/bubble_sort/bubble_sort.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contents/bubble_sort/bubble_sort.md b/contents/bubble_sort/bubble_sort.md index cf188bef0..fe7dff4de 100644 --- a/contents/bubble_sort/bubble_sort.md +++ b/contents/bubble_sort/bubble_sort.md @@ -17,7 +17,7 @@ This means that we need to go through the vector $$\mathcal{O}(n^2)$$ times with {% sample lang="java" %} [import:2-12, lang:"java"](code/java/bubble.java) {% sample lang="js" %} -[import:1-12, lang:"javascript"](code/javascript/bubble.js) +[import:1-11, lang:"javascript"](code/javascript/bubble.js) {% sample lang="py" %} [import:4-9, lang:"python"](code/python/bubblesort.py) {% sample lang="m" %} From c4201186bb231c648afd497f33921fa2bfb66e2f Mon Sep 17 00:00:00 2001 From: CDsigma Date: Sun, 22 Jul 2018 15:41:52 -0700 Subject: [PATCH 4/4] Javascript fix --- contents/bubble_sort/code/javascript/bubble.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contents/bubble_sort/code/javascript/bubble.js b/contents/bubble_sort/code/javascript/bubble.js index 291e2a4e6..c4f57bb8e 100644 --- a/contents/bubble_sort/code/javascript/bubble.js +++ b/contents/bubble_sort/code/javascript/bubble.js @@ -11,7 +11,7 @@ function bubbleSort(arr) { } function main() { - let testArray = [4, 5, 123, 759, -132, 8940, 24, 34, -5]; + const testArray = [4, 5, 123, 759, -132, 8940, 24, 34, -5]; bubbleSort(testArray); console.log(testArray); }