Build a Shape Manager - Step 19

Tell us what’s happening:

Why my code is not working. This is how I would explain it

  • Get element by its ID which is a parameter
  • Assign the method to a variable
  • Check if the variable is falsy
  • if it is then throw a error.
    Isn’t that what is being asked?

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: index.ts */
// User Editable Region
const getElement = (id: string): HTMLElement => {
   let element = document.getElementById(id);
    if(!id){
    Error(`Element not found: ${id}`)
 }
   return element
// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36

Challenge Information:

Build a Shape Manager - Step 19

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/workshop-shape-manager/692804fad5603e1a78d3b589.md at main · freeCodeCamp/freeCodeCamp · GitHub

Hi @mahassan

  1. Is the code checking the variable is falsy.
  2. If it is, throw an error …

For 2, check the Error syntax.

Happy coding

what variable?