- Objective - To create a shape-printer using
console.log. - Purpose - To establish familiarity with basic Javascript.
- Description
- You are provided with a file located at
./assets/js/shapes.js - Edit the file by defining each of the respective function-stubs.
- The objective is to create a program which will return Strings representative of particular shapes with dimensions dependent on user-input.
- You are provided with a file located at
- Begin by forking this project into a personal repository.
- To do this, click the
Forkbutton located at the top right of this page.
- To do this, click the
- Navigate to your github profile to find the newly forked repository.
- Clone the repository from your account into the
~/devdirectory. - Open the newly cloned project in a code editor (Visual Studio Code, for example).
- Complete definition of the
getLinefunction-stub located in./assets/js/shapes.js.- The function should ask user to input
lengthprint a solid line of the requestedlengthusing asterisks.
- The function should ask user to input
- Test the function by calling it from
./assets/js/header-functions.js, then opening the insepctor-tool on the./index.htmldocument.
Input length: 7
Shape:
*******
- Finish defining the
getBoxfunction-stub located in./assets/js/shapes.js.- The function should ask user to input
widthandheightand prints a solid rectangular box of the requested size using asterisks.
- The function should ask user to input
- Test the function by calling it from
./assets/js/header-functions.js, then opening the insepctor-tool on the./index.htmldocument.
Input width: 7
Input height: 4
Shape:
*******
*******
*******
*******
- Finish defining the
getCheckerboardfunction-stub located in./assets/js/shapes.js.- The function should ask user to input
widthandheightand prints a rectangular checkerboard of the requested size using asterisks and spaces (alternating)
- The function should ask user to input
- Test the function by calling it from
./assets/js/header-functions.js, then opening the insepctor-tool on the./index.htmldocument.
Example:
Input width: 11
Input height: 6
Shape:
* * * * * *
* * * * *
* * * * * *
* * * * *
* * * * * *
* * * * *
- Finish defining the
getCrossfunction-stub located in./assets/js/shapes.js.- The function should require input for a
length, and print a diagonal cross of that dimension.
- The function should require input for a
- Test the function by calling it from
./assets/js/header-functions.js, then opening the insepctor-tool on the./index.htmldocument.
Example:
Input length: 8
Shape:
* *
* *
* *
**
**
* *
* *
* *
- Finish defining the
getLowerTrianglefunction-stub located in./assets/js/shapes.js.- The function should require input for a
length, and print the bottom-left half of a square, given the side length.
- The function should require input for a
- Test the function by calling it from
./assets/js/header-functions.js, then opening the insepctor-tool on the./index.htmldocument.
Example:
Input length: 6
Shape:
*
**
***
****
*****
******
- Finish defining the
getUpperTrianglefunction-stub located in./assets/js/shapes.js.- The function should require input for a
length, and print the top-right half of a square, given the side length.
- The function should require input for a
- Test the function by calling it from
./assets/js/header-functions.js, then opening the insepctor-tool on the./index.htmldocument.
Example:
Input length: 5
Shape:
*****
****
***
**
*
-
Finish defining the
getUpsideDownTrapezoidfunction-stub located in./assets/js/shapes.js.- The function should require input for a
widthandheight, and print an upside-down trapezoid of given width and height. - If the input
heightis impossibly large for the givenwidth, then the program should report,Impossible shape!
- The function should require input for a
-
Test the function by calling it from
./assets/js/header-functions.js, then opening the insepctor-tool on the./index.htmldocument.
Example 1:
Input width: 12
Input height: 5
Shape:
************
**********
********
******
****
Example 2:
Input width: 12
Input height: 7
Impossible shape!