Create a new repository on GitHub which has both a Readme.md file and a Node.js .gitignore file. It can be a private repository or a public repository.Clone the newly created repository to your...







  1. Create a new repository on GitHub which has both a Readme.md file and a Node.js .gitignore file. It can be a private repository or a public repository.



  2. Clone the newly created repository to your computer. This is the same step as you performed for the GitHub Classroom repository.






Part 2







  1. Open the repository in VSCode (make sure it is the directory)



  2. Initialize a Nodejs project using "npm init -y"



  3. Edit the Readme.md file to include a favorite quotation.



  4. Write a new Node.js application that prints one of three quotations to the console when run.



    1. You can use the Math.random() function (


      https://www.w3schools.com/js/js_random.asp


      Links to an external site.





      ), and you can directly enter your quotations as strings in the index.js file.









  5. Commit your work, including in the commit message "Created quote app".






Part 3:




Add a new javascript file, exercises.js, and export each of the exercises as a function fromChapter 5.





Make sure to add "type":"module" to your package.json file. This will allow you to use "import" and "export" syntax.







3-1. flattening(list)





Use the


reduce


method in combination with the


concat


method to “flatten” an array of arrays into a single array that has all the elements of the original arrays.


































let








arrays








=





[[



1


,




2


,




3


], [


4


,




5


], [


6


]];



// Your code here.



// → [1, 2, 3, 4, 5, 6]






























3-2. loop(value, test, update, body)





Write a higher-order function


loop


that provides something like a


for


loop statement. It takes a value, a test function, an update function, and a body function. Each iteration, it first runs the test function on the current loop value and stops if that returns false. Then it calls the body function, giving it the current value. Finally, it calls the update function to create a new value and starts from the beginning.













Links to an external site.





When defining the function, you can use a regular loop to do the actual looping.















Links to an external site.








// Your code here.


loop(3,

n


=>


n


>


0,

n


=>


n


-


1,

console.log);

// → 3


// → 2






// → 1
















3-3. everyLoop(array, test)






3-4. everySome(array, test)








Analogous to the


some


method, arrays also have an


every


method. This one returns true when the given function returns true for every element in the array. In a way, some is a version of the || operator that acts on arrays, and every is like the && operator.






Implementtwo versions of


every


(everySome and everyLoop)as a function that takes an array and a predicate function as parameters. Write two versions, one using a loop and one using the


some


method.















Links to an external site.








function


everyLoop(array,

test)


{



// Your code here.



}





function


everySome(array,

test)


{



// Your code here.



}









console.log(everyLoop([1,

3,

5],

n


=>


n





10));



// → true






console.log(everyLoop([2,

4,

16],

n


=>


n





10));



// → false






console.log(everyLoop([],

n


=>


n





10));



// → true












Part 4








  1. Push your changes back to GitHub (using either VS Code or the command line).



  2. Submit the URL to your repository and ensure that the user lucidbard can access it as a collaborator (that's me).









Use this button and confirm that





NOTES:







  • You may overachieve and create a more interesting application for the index.js, as long as you document it in the Readme.md.



  • Ideas include: Joke generation, mad libs, or a simple calculator.



Jan 30, 2023
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here