From b3c9604b88bc3b45d8b54a702a2d9a72e4d066a0 Mon Sep 17 00:00:00 2001 From: al Date: Tue, 15 Oct 2024 16:09:44 -0500 Subject: [PATCH 1/6] Update part-supply.js sorry late --- assignment/scripts/part-supply.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/assignment/scripts/part-supply.js b/assignment/scripts/part-supply.js index dbcb9ddf..b222b4d9 100644 --- a/assignment/scripts/part-supply.js +++ b/assignment/scripts/part-supply.js @@ -4,25 +4,31 @@ console.log('****** Part Supply *******'); // your code does what you expect! // 1. Create a variable called 'partsNeeded' with a value of the number 40. -console.log('1. Create partsNeeded:'); +let 'partsneeded=40 +console.log('1. Create partsNeeded variable with value of 40); // 2. Create a variable called 'supplyChanges' whose value is an array containing // the following numbers: 3, 5, -6, 0, 7, 11. -console.log('2. Create supplyChanges:'); +let supplychangeArray= [3,5,-6,0,7,11]; +console.log('2.created supplyChangesArray:'); // 3. Create a variable called 'secondItem' and assign it the value of the second // item in the 'supplyChanges' array. +let secondItem = 5 console.log('3. Access the second value of supplyChanges:'); // 4. The last value in the 'supplyChanges' array was added by mistake. // Remove it from the array and store it inside a new variable called 'removedItem'. +remove supplychangeArray.push(11) console.log('4. Remove the last value from supplyChanges:'); // 5. A delivery of 25 more parts arrived. Add the value 25 to the end of the array +let parts = ('25') +supplychangesArray.index(5), [25]; console.log('5. Add the value 25 into supplyChanges.'); @@ -33,6 +39,10 @@ console.log('5. Add the value 25 into supplyChanges.'); // - If the value is a positive number, push it into the 'positives' array. // - If the value is a negative number, push it into the 'negatives' array. // - If the value is a zero, push it into the 'zeroes' array. +let positiveArray = (); +let negativeArray =(); +let zerosArray = (); +for (i=0; i>3; i+-); console.log('6. Looping through supplyChanges to populate arrays with positive, negative, and zero values:'); @@ -41,13 +51,19 @@ console.log('6. Looping through supplyChanges to populate arrays with positive, // ***** STRETCH GOALS ********************************************* // 7. Rewrite the 'for' loop from #6 as a 'for...of' loop. Instead of 'positives', // 'negatives', and 'zeroes', create three new arrays named 'stretchPositives', -// 'stretchNegatives', and 'stretchZeroes'. +// 'stretchNegatives', and 'stretchZeroes'. +let stretchPositiveArray = (); + let stretchNegativeArray= (); +let StretchZeroesArray= (); +for (i=0, i>3; i+-); console.log('7. Looping through supplyChanges to populate more arrays with positive, negative, and zero values:'); // 8. Create a variable called 'totalParts' and assign it a value of 0. // Then, write a loop that adds each value of the 'supplyChanges' // array to the 'totalParts' variable. +let totalParts = 0 +let('i=0 + totalsparts = supplyChanges'); console.log('8. Looping through supplyChanges to calculate the sum:'); @@ -62,6 +78,10 @@ console.log('8. Looping through supplyChanges to calculate the sum:'); // the value of 'parts' should reflect how many parts are // "left over," and the value of 'boxesFilled' should reflect // how many boxes were filled. +let parts = 572 +let boxesFilled = 0 +for (i=572/7); i== + boxesFilled console.log('9. Filling boxes with a "while" loop'); From 34ae106f0be80631b46432e09eccc61e07eefee6 Mon Sep 17 00:00:00 2001 From: al cotton Date: Thu, 31 Oct 2024 15:25:33 -0500 Subject: [PATCH 2/6] unit 33 commit --- assignment/index.html | 14 ++- assignment/scripts/part-supply.js | 97 ++++++++++------- launch.json | 15 +++ part-supply.js | 111 ++++++++++++++++++++ test/reporter.js => reporter.js | 0 test/test.js => test.js | 0 package-lock.json => test/package-lock.json | 0 7 files changed, 195 insertions(+), 42 deletions(-) create mode 100644 launch.json create mode 100644 part-supply.js rename test/reporter.js => reporter.js (100%) rename test/test.js => test.js (100%) rename package-lock.json => test/package-lock.json (100%) diff --git a/assignment/index.html b/assignment/index.html index 57b44a12..28731edc 100644 --- a/assignment/index.html +++ b/assignment/index.html @@ -16,8 +16,14 @@

Unit 3, Part 3

- -
+ +
    My Questions for the Week! +
      1. having trouble with loading my page in vs code.
    +
      2. had a bit of trouble with remembering Array but finally got it! +
        3. Will or can we expand our knowledge base with Prime when this course is over?
      +
    +
+
In addition to passing tests, we will be looking @@ -38,11 +44,11 @@

Unit 3, Part 3

-

+

I do not have any questions at this point. Just getting really excited about the comming weeks.

- + diff --git a/assignment/scripts/part-supply.js b/assignment/scripts/part-supply.js index b222b4d9..83b5ac2a 100644 --- a/assignment/scripts/part-supply.js +++ b/assignment/scripts/part-supply.js @@ -4,32 +4,31 @@ console.log('****** Part Supply *******'); // your code does what you expect! // 1. Create a variable called 'partsNeeded' with a value of the number 40. -let 'partsneeded=40 -console.log('1. Create partsNeeded variable with value of 40); +let partsNeeded = 40; +onsole.log('Parts needed: 40'); // 2. Create a variable called 'supplyChanges' whose value is an array containing // the following numbers: 3, 5, -6, 0, 7, 11. -let supplychangeArray= [3,5,-6,0,7,11]; -console.log('2.created supplyChangesArray:'); +let suppluChangesArray= [3, 5, -6, 0, 7, 11]; +console.log('Supply changes: 3,5,-6,0,7,11'); // 3. Create a variable called 'secondItem' and assign it the value of the second // item in the 'supplyChanges' array. -let secondItem = 5 -console.log('3. Access the second value of supplyChanges:'); +let secondItem = supplyChanges(1); +console.log('access the second value of supplyChangesArray: 5') // 4. The last value in the 'supplyChanges' array was added by mistake. // Remove it from the array and store it inside a new variable called 'removedItem'. -remove supplychangeArray.push(11) -console.log('4. Remove the last value from supplyChanges:'); - + removeItem = supplyChangesArray.push(5); + let removedItem =11; +console.log('Remove the last value from supplyChangesArray: 11'); // 5. A delivery of 25 more parts arrived. Add the value 25 to the end of the array -let parts = ('25') -supplychangesArray.index(5), [25]; -console.log('5. Add the value 25 into supplyChanges.'); +let supplyChanges = supplyChangesArray. +console.log('Add the value 25 into supplyChanges.'); // 6. Create three new variables named 'positives', 'negatives', and @@ -39,11 +38,22 @@ console.log('5. Add the value 25 into supplyChanges.'); // - If the value is a positive number, push it into the 'positives' array. // - If the value is a negative number, push it into the 'negatives' array. // - If the value is a zero, push it into the 'zeroes' array. -let positiveArray = (); -let negativeArray =(); -let zerosArray = (); -for (i=0; i>3; i+-); -console.log('6. Looping through supplyChanges to populate arrays with positive, negative, and zero values:'); + +let positives = []; +let negatives = []; +let zeroes = []; + +for (let i = 0; i < supplyChangesArray.length; i++) { + if (supplyChangesArray[i] > 0) { + positives.push(supplyChangesArray[i]); + } else if (supplyChangesArray[i] < 0) { + negatives.push(supplyChangesArray[i]); + } else { + zeroes.push(supplyChangesArray[i]); + } +} + +console.log('Looping through supplyChanges to populate arrays with positive, negative, and zero values:', positives, negatives, zeroes); @@ -51,20 +61,32 @@ console.log('6. Looping through supplyChanges to populate arrays with positive, // ***** STRETCH GOALS ********************************************* // 7. Rewrite the 'for' loop from #6 as a 'for...of' loop. Instead of 'positives', // 'negatives', and 'zeroes', create three new arrays named 'stretchPositives', -// 'stretchNegatives', and 'stretchZeroes'. -let stretchPositiveArray = (); - let stretchNegativeArray= (); -let StretchZeroesArray= (); -for (i=0, i>3; i+-); -console.log('7. Looping through supplyChanges to populate more arrays with positive, negative, and zero values:'); +for (let value of supplyChangesArray) { + if (value > 0) { + stretchPositives.push(value); + } else if (value < 0) { + stretchNegatives.push(value); + } else { + stretchZeroes.push(value); + } +} +console.log('Looping through supplyChanges to populate more arrays with positive, negative, and zero values:', stretchPositives, stretchNegatives, stretchZeroes); + if (supplyChangesArray = 0) { + strerchZeroes = supplyChangesArray.push(); + } +console.log('Looping through supplyChanges to populate more arrays with positive, negative, and zero values:'); +for (let i = 0; i < supplyChangesArray.length; i++) { + totalParts += supplyChangesArray[i]; +} // 8. Create a variable called 'totalParts' and assign it a value of 0. // Then, write a loop that adds each value of the 'supplyChanges' // array to the 'totalParts' variable. -let totalParts = 0 -let('i=0 + totalsparts = supplyChanges'); -console.log('8. Looping through supplyChanges to calculate the sum:'); +let totalParts = 0; +for (let i = 0; i < supplyChanges.length; i++) + +console.log('Looping through supplyChanges to calculate the sum:'); // 9. We have a large stash of parts in our warehouse that we @@ -72,20 +94,19 @@ console.log('8. Looping through supplyChanges to calculate the sum:'); // parts in total, and each box holds 7 parts. // Create two variables: // 1. 'parts': Set its value to 572 -// 2. 'boxesFilled': Set its value to 0 -// Use a 'while' loop to keep adding parts to boxes UNTIL -// no more boxes can be filled. When the loop is finished, -// the value of 'parts' should reflect how many parts are +while (parts >= 7) { + parts -= 7; + boxesFilled++; +} +console.log('9. Filling boxes with a "while loop"', parts, boxesFilled); // "left over," and the value of 'boxesFilled' should reflect // how many boxes were filled. -let parts = 572 -let boxesFilled = 0 -for (i=572/7); i== - boxesFilled -console.log('9. Filling boxes with a "while" loop'); - - - +let parts = 572; +let boxesFilled = 0; +while (parts > 0) + parts = parts -7; +boxesFilled = boxesFilled +1; +console('').log('9. Filling boxes with a "while loop"'); // DO NOT MODIFY // Used for automated testing diff --git a/launch.json b/launch.json new file mode 100644 index 00000000..2ba986f6 --- /dev/null +++ b/launch.json @@ -0,0 +1,15 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "chrome", + "request": "launch", + "name": "Launch Chrome against localhost", + "url": "http://localhost:8080", + "webRoot": "${workspaceFolder}" + } + ] +} \ No newline at end of file diff --git a/part-supply.js b/part-supply.js new file mode 100644 index 00000000..a694f809 --- /dev/null +++ b/part-supply.js @@ -0,0 +1,111 @@ +console.log('****** Part Supply *******'); +// ***** REQUIRED FEATURES ********************************************* +// For each question, be sure to use console.log statements to ensure that +// your code does what you expect! + +// 1. Create a variable called 'partsNeeded' with a value of the number 40. +let partsNeeded = 40; +console.log('1. Parts needed: 40'); + + +// 2. Create a variable called 'supplyChanges' whose value is an array containing +// the following numbers: 3, 5, -6, 0, 7, 11. +let suppluChangesArray = [3, 5, -6, 0, 7, 11]; +console.log('2. Supply changes: 3,5,-6,0,7,11'); + +// 3. Create a variable called 'secondItem' and assign it the value of the second +// item in the 'supplyChanges' array. +let secondItem = supplyChanges(1); +console.log('3. access the second value of supplyChangesArray 5') + +// 4. The last value in the 'supplyChanges' array was added by mistake. +// Remove it from the array and store it inside a new variable called 'removedItem'. +let removedItem = supplyChangesArray.pop(); +console.log('4. Remove the last value from supplyChangesArray 11'); + +// 5. A delivery of 25 more parts arrived. Add the value 25 to the end of the array +let supplyChanges = suppluChangesArray. +console.log('5. Add the value 25 into supplyChanges.'); + + +// 6. Create three new variables named 'positives', 'negatives', and +// 'zeroes' whose values are empty arrays. Then, write a for loop +// that loops through the 'supplyChanges' array. For each iteration of +// the loop: +// - If the value is a positive number, push it into the 'positives' array. +// - If the value is a negative number, push it into the 'negatives' array. +// - If the value is a zero, push it into the 'zeroes' array. + +let positives = []; +let negative = []; +let zero = []; +for (let i = 0; i < supplyChangesArray.length; i++) { + if (supplyChangesArray[i] > 0) { + positives.push(supplyChangesArray[i]); + } else if (supplyChangesArray[i] < 0) { + negatives.push(supplyChangesArray[i]); + } else { + zeroes.push(supplyChangesArray[i]); + } +} +console.log('6. Looping through supplyChanges to populate arrays with positive, negative, and zero values:'); + + + + +// ***** STRETCH GOALS ********************************************* +// 7. Rewrite the 'for' loop from #6 as a 'for...of' loop. Instead of 'positives', +// 'negatives', and 'zeroes', create three new arrays named 'stretchPositives', +// 'stretchNegatives', and 'stretchZeroes'. + +console.log('7. Looping through supplyChanges to populate more arrays with positive, negative, and zero values:'); + + +// 8. Create a variable called 'totalParts' and assign it a value of 0. +// Then, write a loop that adds each value of the 'supplyChanges' +// array to the 'totalParts' variable. +let totalParts = 0; +for (let i = 0; i < supplyChanges.length; i++) + +console.log('8. Looping through supplyChanges to calculate the sum:'); + + +// 9. We have a large stash of parts in our warehouse that we +// need to box up and get ready for shipment. There are 572 +// parts in total, and each box holds 7 parts. +// Create two variables: +// 1. 'parts': Set its value to 572 +// 2. 'boxesFilled': Set its value to 0 +// Use a 'while' loop to keep adding parts to boxes UNTIL +// no more boxes can be filled. When the loop is finished, +// the value of 'parts' should reflect how many parts are +// "left over," and the value of 'boxesFilled' should reflect +// how many boxes were filled. +let parts = 572; +let boxesFilled = 0; +while (parts > 0) + parts = parts -7; +boxesFilled = boxesFilled +1; +console('').log('9. Filling boxes with a "while loop"'); + +// DO NOT MODIFY +// Used for automated testing +try { + module.exports = { + partsNeeded: typeof partsNeeded !== 'undefined' ? partsNeeded : undefined, + supplyChanges: typeof supplyChanges !== 'undefined' ? supplyChanges : undefined, + secondItem: typeof secondItem !== 'undefined' ? secondItem : undefined, + removedItem: typeof removedItem !== 'undefined' ? removedItem : undefined, + positives: typeof positives !== 'undefined' ? positives : undefined, + negatives: typeof negatives !== 'undefined' ? negatives : undefined, + zeroes: typeof zeroes !== 'undefined' ? zeroes : undefined, + stretchPositives: typeof stretchPositives !== 'undefined' ? stretchPositives : undefined, + stretchNegatives: typeof stretchNegatives !== 'undefined' ? stretchNegatives : undefined, + stretchZeroes: typeof stretchZeroes !== 'undefined' ? stretchZeroes : undefined, + totalParts: typeof totalParts !== 'undefined' ? totalParts : undefined, + parts: typeof parts !== 'undefined' ? parts : undefined, + boxesFilled: typeof boxesFilled !== 'undefined' ? boxesFilled : undefined, + } +} catch (e) { + // Do nothing +} diff --git a/test/reporter.js b/reporter.js similarity index 100% rename from test/reporter.js rename to reporter.js diff --git a/test/test.js b/test.js similarity index 100% rename from test/test.js rename to test.js diff --git a/package-lock.json b/test/package-lock.json similarity index 100% rename from package-lock.json rename to test/package-lock.json From 0d1e72567d9a966657de07be09c08841fb375ad8 Mon Sep 17 00:00:00 2001 From: al cotton Date: Sun, 17 Nov 2024 15:55:59 -0600 Subject: [PATCH 3/6] updates on assignment 3 --- assignment/index.html | 1 - assignment/scripts/part-supply.js | 11 +++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/assignment/index.html b/assignment/index.html index 28731edc..eb33bfd9 100644 --- a/assignment/index.html +++ b/assignment/index.html @@ -49,6 +49,5 @@

Unit 3, Part 3

- diff --git a/assignment/scripts/part-supply.js b/assignment/scripts/part-supply.js index 83b5ac2a..0404e449 100644 --- a/assignment/scripts/part-supply.js +++ b/assignment/scripts/part-supply.js @@ -5,20 +5,19 @@ console.log('****** Part Supply *******'); // 1. Create a variable called 'partsNeeded' with a value of the number 40. let partsNeeded = 40; -onsole.log('Parts needed: 40'); +console.log('Parts needed: 40'); // 2. Create a variable called 'supplyChanges' whose value is an array containing // the following numbers: 3, 5, -6, 0, 7, 11. -let suppluChangesArray= [3, 5, -6, 0, 7, 11]; +let supplyChangesArray= [3, 5, -6, 0, 7, 11]; console.log('Supply changes: 3,5,-6,0,7,11'); // 3. Create a variable called 'secondItem' and assign it the value of the second // item in the 'supplyChanges' array. -let secondItem = supplyChanges(1); -console.log('access the second value of supplyChangesArray: 5') - +let secondItem = [1]; +console.log('access the second value of supplyChangesArray:5'); // 4. The last value in the 'supplyChanges' array was added by mistake. // Remove it from the array and store it inside a new variable called 'removedItem'. @@ -28,7 +27,7 @@ console.log('Remove the last value from supplyChangesArray: 11'); // 5. A delivery of 25 more parts arrived. Add the value 25 to the end of the array let supplyChanges = supplyChangesArray. -console.log('Add the value 25 into supplyChanges.'); +console.log('Add the value into supplyChangesArray: 25'); // 6. Create three new variables named 'positives', 'negatives', and From 3e458b1248a7942304e6f45bbab21c35457520cc Mon Sep 17 00:00:00 2001 From: al cotton Date: Sun, 17 Nov 2024 16:01:12 -0600 Subject: [PATCH 4/6] unit 3.3 update --- part-supply.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/part-supply.js b/part-supply.js index a694f809..96c642b8 100644 --- a/part-supply.js +++ b/part-supply.js @@ -4,12 +4,16 @@ console.log('****** Part Supply *******'); // your code does what you expect! // 1. Create a variable called 'partsNeeded' with a value of the number 40. +// creating a variable called partsNeeded and setting its value @ 40 +//console.log(partsNeeded) + let partsNeeded = 40; console.log('1. Parts needed: 40'); // 2. Create a variable called 'supplyChanges' whose value is an array containing // the following numbers: 3, 5, -6, 0, 7, 11. +// creating a variable called supplyChange and setting its value to an Array called supplyChangesArray let suppluChangesArray = [3, 5, -6, 0, 7, 11]; console.log('2. Supply changes: 3,5,-6,0,7,11'); From af62be5a4692b21abcf9e413e9016d7d46278896 Mon Sep 17 00:00:00 2001 From: al cotton Date: Sun, 17 Nov 2024 16:27:18 -0600 Subject: [PATCH 5/6] updated js --- assignment/scripts/part-supply.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assignment/scripts/part-supply.js b/assignment/scripts/part-supply.js index 0404e449..069a6fc3 100644 --- a/assignment/scripts/part-supply.js +++ b/assignment/scripts/part-supply.js @@ -26,8 +26,8 @@ console.log('access the second value of supplyChangesArray:5'); console.log('Remove the last value from supplyChangesArray: 11'); // 5. A delivery of 25 more parts arrived. Add the value 25 to the end of the array -let supplyChanges = supplyChangesArray. -console.log('Add the value into supplyChangesArray: 25'); +let supplyChanges = supplyChangesArray.push +console.log('Add the value 25 into supplyChangesArray: 25'); // 6. Create three new variables named 'positives', 'negatives', and From df8c0bbab04270717546c02d26f6cb22d2af8922 Mon Sep 17 00:00:00 2001 From: al cotton Date: Sun, 17 Nov 2024 21:17:54 -0600 Subject: [PATCH 6/6] unit 3.3 js --- assignment/scripts/part-supply.js | 43 +++++++++++++++++++------------ 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/assignment/scripts/part-supply.js b/assignment/scripts/part-supply.js index 069a6fc3..a5eccfb1 100644 --- a/assignment/scripts/part-supply.js +++ b/assignment/scripts/part-supply.js @@ -59,7 +59,10 @@ console.log('Looping through supplyChanges to populate arrays with positive, neg // ***** STRETCH GOALS ********************************************* // 7. Rewrite the 'for' loop from #6 as a 'for...of' loop. Instead of 'positives', -// 'negatives', and 'zeroes', create three new arrays named 'stretchPositives', +let stretchPositives = []; +let stretchNegatives = []; +let stretchZeroes = []; + for (let value of supplyChangesArray) { if (value > 0) { stretchPositives.push(value); @@ -70,6 +73,18 @@ for (let value of supplyChangesArray) { } } +console.log('Looping through supplyChanges to populate more arrays with positive, negative, and zero values:', stretchPositives, stretchNegatives, stretchZeroes); +// 'negatives', and 'zeroes', create three new arrays named 'stretchPositives', +for (let value of supplyChangesArray) { + if (value > 0) { + stretchPositives.push(value); + } else if (value < 0) { + stretchNegatives.push(value); + } else { + stretchZeroes.push(value); + } +} + console.log('Looping through supplyChanges to populate more arrays with positive, negative, and zero values:', stretchPositives, stretchNegatives, stretchZeroes); if (supplyChangesArray = 0) { strerchZeroes = supplyChangesArray.push(); @@ -83,29 +98,25 @@ for (let i = 0; i < supplyChangesArray.length; i++) { // Then, write a loop that adds each value of the 'supplyChanges' // array to the 'totalParts' variable. let totalParts = 0; -for (let i = 0; i < supplyChanges.length; i++) - +for (let i = 0; i < supplyChanges.length; i++){ + totalParts += supplyChanges[1]; console.log('Looping through supplyChanges to calculate the sum:'); - +} // 9. We have a large stash of parts in our warehouse that we // need to box up and get ready for shipment. There are 572 // parts in total, and each box holds 7 parts. // Create two variables: // 1. 'parts': Set its value to 572 -while (parts >= 7) { - parts -= 7; - boxesFilled++; -} -console.log('9. Filling boxes with a "while loop"', parts, boxesFilled); -// "left over," and the value of 'boxesFilled' should reflect -// how many boxes were filled. +// 2. 'boxesFilled': This variable should be assigned the result of dividing 'parts' by 7. let parts = 572; -let boxesFilled = 0; -while (parts > 0) - parts = parts -7; -boxesFilled = boxesFilled +1; -console('').log('9. Filling boxes with a "while loop"'); +let boxesFilled = Math.floor(parts / 7); +let leftoverParts = parts % 7; + +console.log('Total parts:', parts); +console.log('Boxes filled:', boxesFilled); +console.log('Leftover parts:', leftoverParts); + // DO NOT MODIFY // Used for automated testing