File tree 6 files changed +93
-1
lines changed
6 files changed +93
-1
lines changed Original file line number Diff line number Diff line change
1
+ var msg = "Hello World" ;
2
+ console . log ( msg ) ;
3
+
4
+ const prompt = require { 'prompt-sync' } { } ;
5
+ const name = prompt ( "What is your name?" ) ;
6
+ console . log ( "Hey there $(name)" ) ;
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " exampleproject" ,
3
+ "version" : " 1.0.0" ,
4
+ "description" : " " ,
5
+ "main" : " index.js" ,
6
+ "scripts" : {
7
+ "test" : " echo \" Error: no test specified\" && exit 1"
8
+ },
9
+ "keywords" : [],
10
+ "author" : " " ,
11
+ "license" : " ISC" ,
12
+ "dependencies" : {
13
+ "prompt-sync" : " ^4.2.0"
14
+ }
15
+ }
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ console.log('myName: ' + myName);
15
15
console . log ( 'trueValue: ' + trueValue ) ;
16
16
console . log ( 'price: ' + price ) ;
17
17
console . log ( 'nullVar: ' + nullVar ) ;
18
- console . log ( 'und: ' + und ) ;
18
+ console . log ( 'und: ' + und ) ;
19
19
20
20
// ******* Variable Scope
21
21
Original file line number Diff line number Diff line change 7
7
< body >
8
8
< script src ="./../PacktDataStructuresAlgorithms.min.js "> </ script >
9
9
< script src ="01-BubbleSort.js "> </ script >
10
+
11
+ < h2 > Bubble Sort</ h2 >
12
+
13
+ < form >
14
+ < label for = "numberOfValues "> Number of values:</ label > < br >
15
+ < input type = "text " id = "numberOfValues " name = "numberOfValues " value = "0 "> < br >
16
+ < input type = "button " value = "Submit " onCLick = "callJavaScript() ">
17
+ </ form >
10
18
</ body >
11
19
</ html >
Original file line number Diff line number Diff line change 1
1
const { bubbleSort } = PacktDataStructuresAlgorithms ;
2
2
3
+ function RunBubbleSort ( ) {
4
+ var valuepicked = document . getElementById ( 'numberOfValues' ) . value ;
5
+ if ( valuepicked > 0 ) {
6
+ const array = bubbleSort ( createNonSortedArray ( valuepicked ) ) ;
7
+ console . log ( array ) ;
8
+ } else {
9
+ console . error ( "" ) ;
10
+ alert ( "invalid input" ) ;
11
+ }
12
+ }
13
+
3
14
function createNonSortedArray ( ) {
4
15
var array = [ ] ;
5
16
for ( let i = 5 ; i > 0 ; i -- ) {
@@ -8,5 +19,14 @@ function createNonSortedArray(){
8
19
return array ;
9
20
}
10
21
22
+ function createNonSortedArray ( Parameter ) {
23
+ var array = [ ] ;
24
+ for ( let i = Parameter ; i > 0 ; i -- ) {
25
+ array . push ( i ) ;
26
+ }
27
+ return array ;
28
+ }
29
+
30
+
11
31
const array = bubbleSort ( createNonSortedArray ( ) ) ;
12
32
console . log ( array ) ;
You can’t perform that action at this time.
0 commit comments