- Setup:
- Create following folder/file structure:
.
├── index.html
└── js
└── index.js| console.log('I am connected!'); | |
| const theCanvas = document.getElementById('canvas'); | |
| const ctx = theCanvas.getContext('2d'); | |
| // create new image object | |
| const img = new Image(); | |
| // "src" has to point as the image is used in HTML file | |
| img.src = |
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
| <meta http-equiv="X-UA-Compatible" content="ie=edge" /> | |
| <title>Canvas - Pattern and Shadow</title> | |
| </head> | |
| <body> |
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
| <meta http-equiv="X-UA-Compatible" content="ie=edge" /> | |
| <title>Canvas Animations</title> | |
| </head> | |
| <body> |
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
| <meta http-equiv="X-UA-Compatible" content="ie=edge" /> | |
| <title>Canvas Animations</title> | |
| </head> | |
| <body> |
| // ************************************************************************************ | |
| // https://www.codewars.com/kata/56747fd5cb988479af000028/train/javascript | |
| // You are going to be given a word. Your job is to return the middle character of the word. | |
| // If the word's length is odd, return the middle character. If the word's length is even, | |
| // return the middle 2 characters. | |
| // Examples: | |
| // getMiddle("test") should return "es" | |
| // getMiddle("testing") should return "t" | |
| // getMiddle("middle") should return "dd" |
| /* | |
| FOR TEST EXAMPLES AND DIFFERENT MATCHERS (`toEqual`, `toBe`, `not.toBe`, etc): | |
| https://jasmine.github.io/api/3.4/global | |
| */ | |
| describe('centsToDecimals function', () => { | |
| // Describes the suite / group of tests | |
| // Use this test suite as a starting point/reference. |
| // 1: What is the expected output? And why? | |
| function print() { | |
| console.log(1); | |
| setTimeout(() => console.log(2), 1000); | |
| setTimeout(() => console.log(3), 0); | |
| console.log(4); | |
| } | |
| print(); // => ??? |