-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsertionSort.js
More file actions
35 lines (28 loc) · 885 Bytes
/
insertionSort.js
File metadata and controls
35 lines (28 loc) · 885 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// const insertionSort = arr => {
// for (let i = 1; i < arr.length; i++) {
// let j = i - 1;
// let temp = arr[i];
// while (j >= 0 && arr[j] > temp) {
// arr[j + 1] = arr[j];
// arr[j] = temp;
// j--;
// }
// arr[j + 1] = temp;
// }
// return arr;
// };
// console.log(insertionSort([2, 4, 2, 1, 10, 8, 7, 4]));
// Declare second integer, double, and String variables.
// Read and save an integer, double, and String to your variables.
// Print the sum of both integer variables on a new line.
// Print the sum of the double variables on a new line.
// Concatenate and print the String variables on a new line
// The 's' variable above should be printed first.
// let i = 4;
// let d = 4.0;
// let s = 'HackerRank ';
// console.log(i + i);
// console.log(d + d);
// console.log(s + s);
// console.log(s + i);
// console.log(s + d);