From bb6fb1ae682423285ac4a4228250c666c84cfc69 Mon Sep 17 00:00:00 2001 From: amanullahakhundzada Date: Mon, 15 Aug 2022 15:43:57 -0700 Subject: [PATCH 1/3] Exercise #1,#2,#3,#4,#5 --- app.js | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index 4a83d9c..7f94c17 100644 --- a/app.js +++ b/app.js @@ -2,6 +2,73 @@ console.log("Hello World!\n==========\n"); // Exercise 1 Section console.log("EXERCISE 1:\n==========\n"); - + +for (let i=1;i<=100;i++) +{ + if( i%2 == 0 ) { + continue; + }else { + console.log(i); + } +} // Exercise 2 Section console.log("EXERCISE 2:\n==========\n"); + + +for (let j=1;j<=100;j++) +{ + if (j%3==0 && j%5==0) + {console.log("FIZZBUZZ",j);} + else if (j%5==0) + { console.log("BUZZ",j);} + else if (j%3==0 ) + { console.log("FIZZ",j);} + // else {continue; } +} +console.log("EXERCISE 3:\n==========\n"); +let x=1; + +let h=1; +while(h<=100){ + if (h%3==0 && h%5==0) + {console.log("FIZZBUZZ",h);} + else if (h%5==0) + { console.log("BUZZ",h);} + else if (h%3==0 ) + { console.log("FIZZ",h);} + h++; + +} +console.log("EXERCISE 4:\n==========\n"); + +let value =Math.round((Math.random() * 500)); // creates a random number between 0 and 500 +let n =Math.round(Math.random() * (500 - 100) + 100); // creates a random number between 100 and 500 + +for(let f=0;f<=n;f++) +{ + if(f==value) + {console.log("Found value",f); + break;} + else if(f==n) { + console.log("Did not find value"); + } + +} + + + +console.log("EXERCISE 5:\n==========\n"); +let fizzDivisor = Math.round(Math.random() * (10 - 1) + 1); +let buzzDivisor = Math.round(Math.random() * (10 - 1) + 1); +let m = Math.round(Math.random() * (1000 - 1) + 1); +let start = Math.round(Math.random() * (10 - 1) + 1); +for(start=1;start<=m;start++) +{ + if (start%3==0 && start%5==0) + {console.log("FizzDivisorBuzzDivisor",start);} + else if (start%5==0) + { console.log("buzzDivisor",start);} + else if (start%3==0 ) + { console.log("FizzDivisor",start);} + +} \ No newline at end of file From 8b133ca884cd1f126a0398ca5b6c269809cdceb4 Mon Sep 17 00:00:00 2001 From: amanullahakhundzada Date: Mon, 15 Aug 2022 17:46:59 -0700 Subject: [PATCH 2/3] missing code of 3rd exercise has been added which i forgot --- app.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app.js b/app.js index 7f94c17..68a4ad4 100644 --- a/app.js +++ b/app.js @@ -27,7 +27,12 @@ for (let j=1;j<=100;j++) } console.log("EXERCISE 3:\n==========\n"); let x=1; +do{ if(x%2==1){ + console.log(x);} + x++; + +}while(x<100) let h=1; while(h<=100){ if (h%3==0 && h%5==0) From dc51c14f706441d401d962bf7a8230a7d883969c Mon Sep 17 00:00:00 2001 From: amanullahakhundzada Date: Tue, 16 Aug 2022 11:12:44 -0700 Subject: [PATCH 3/3] last exercise has been updated --- app.js | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/app.js b/app.js index 68a4ad4..8cb2267 100644 --- a/app.js +++ b/app.js @@ -30,9 +30,17 @@ let x=1; do{ if(x%2==1){ console.log(x);} x++; +}while(x<=100) +// let whileI=0; +// while(whileI<=100) +// { +// if(whileI%2==1) { +// console.log(whileI) +// } + +// } -}while(x<100) let h=1; while(h<=100){ if (h%3==0 && h%5==0) @@ -54,7 +62,7 @@ for(let f=0;f<=n;f++) if(f==value) {console.log("Found value",f); break;} - else if(f==n) { + else if(f==n) { console.log("Did not find value"); } @@ -63,17 +71,19 @@ for(let f=0;f<=n;f++) console.log("EXERCISE 5:\n==========\n"); + let fizzDivisor = Math.round(Math.random() * (10 - 1) + 1); let buzzDivisor = Math.round(Math.random() * (10 - 1) + 1); -let m = Math.round(Math.random() * (1000 - 1) + 1); +let m = Math.round(Math.random() * (1000 - 1) + 1); let start = Math.round(Math.random() * (10 - 1) + 1); -for(start=1;start<=m;start++) + +for(let l=start;l<=m;l++) { - if (start%3==0 && start%5==0) - {console.log("FizzDivisorBuzzDivisor",start);} - else if (start%5==0) - { console.log("buzzDivisor",start);} - else if (start%3==0 ) - { console.log("FizzDivisor",start);} + if (l%fizzDivisor==0 && l%buzzDivisor==0) + {console.log(l,`FizzDuzz ${fizzDivisor} and ${buzzDivisor}`);} + else if (l%buzzDivisor==0) + { console.log(l,`buzz = ${buzzDivisor}`);} + else if (l%fizzDivisor==0 ) + { console.log(l,`Fizz = ${fizzDivisor}`);} -} \ No newline at end of file +} \ No newline at end of file