Uncaught referenceError

function bankrobbery(){
    const heroes = ['spiderman', 'batman', 'superman', 'catwomen'];
    function cryforhelp(){
        for (let hero of heroes) {
            console.log( `please help me, $(hero) `);
        }

    }
    cryforhelp();
}
when i execute this in a html console, i  get the error : 
"Uncaught ReferenceError: bankrobbery is not defined"

I made a blank html page, and filled in the script element into it ...

? I don't understand the error .. ?
for (let hero of heroes) {
            console.log( `please help me, $(hero) `);
}

should be

for (let hero of heroes) {
            console.log( `please help me, ${hero} `);
 }
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script scr="lexicalScope.js"></script>
</body>
</html>

This is my html .
I have fixed the bug, but it’s html ?

scr is not the correct attribute.

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script

1 Like

yeah, i saw, it must be src … Thanks