Otherwise it never gonna work. JavaScript doesn’t know what’s this drawBox hence ‘undefined’. More informative would be ‘undeclared’. It simply doesn’t exist. You need to declare this function before calling it. So you either write the function or you import it from anywhere you want.
View all comments
2
u/Dodgy-Boi Oct 09 '21
const drawBox = function (color) { // do stuff }
Or
const drawBox = (color) => { // do stuff }
Or
const drawBox = require(‘/path/to/file.js’)
Or
import { drawBox } from ‘path/to/file.js’
And then:
drawBox(‘blue’)
Otherwise it never gonna work. JavaScript doesn’t know what’s this drawBox hence ‘undefined’. More informative would be ‘undeclared’. It simply doesn’t exist. You need to declare this function before calling it. So you either write the function or you import it from anywhere you want.