JavaScript drawing - Exercises, Practice, Solution
JavaScript drawing [6 exercises with solution]
[An editor is available at the bottom of the page to write and execute the scripts.]
1. Write a JavaScript program to draw the following rectangular shape. Go to the editor
Expected Output :
Click me to see the solution
2. Write a JavaScript program to draw a circle. Go to the editor
Expected Output :
Click me to see the solution
3. Write a JavaScript program to draw two intersecting rectangles, one of which has alpha transparency. Go to the editor
Expected Output :
Click me to see the solution
4. Write a JavaScript program to draw the following right-angled triangle. Go to the editor
Expected Output :
Click me to see the solution
5. Write a JavaScript program to draw the following diagram [use moveto() function]. Go to the editor
Expected Output :
Click me to see the solution
6. Write a JavaScript program to draw the following diagram [diagonal, white to black circles]. Go to the editor
Expected Output :
Click me to see the solution
More to Come !
* To run the code mouse over on Result panel and click on 'RERUN' button.*
Live Demo:
See the Pen javascript-common-editor by w3resource (@w3resource) on CodePen.
Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.
JavaScript: Tips of the Day
Tagged template literals
function getPersonInfo(one, two, three) { console.log(one); console.log(two); console.log(three); } const person = 'Lydia'; const age = 21; getPersonInfo`${person} is ${age} years old`;
If you use tagged template literals, the value of the first argument is always an array of the string values. The remaining arguments get the values of the passed expressions!
Ref: https://bit.ly/323Y0P6
- Exercises: Weekly Top 12 Most Popular Topics
- Pandas DataFrame: Exercises, Practice, Solution
- Conversion Tools
- JavaScript: HTML Form Validation
- SQL Exercises, Practice, Solution - SUBQUERIES
- C Programming Exercises, Practice, Solution : For Loop
- Python Exercises, Practice, Solution
- Python Data Type: List - Exercises, Practice, Solution
- C++ Basic: Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - exercises on Employee Database
- SQL Exercises, Practice, Solution - exercises on Movie Database
- SQL Exercises, Practice, Solution - exercises on Soccer Database
- C Programming Exercises, Practice, Solution : Recursion