if statement not working

This is a little example of the code i am using on my website. But when i write " $w ( ‘#text22’ ). text = String ( cr );" it says “cannot find name cr”. Can somebody please help?

let z = 8*9 ;

if ( $w ( ‘#input1’ ). value === String (10)) {
let cr = z *10;
}
$w ( ‘#text22’ ). text = String ( cr );

The let and const are lock-scoped local variables. They available only on the block scope where they are declared.

Move your let on the scope above.

let z = 8*9;
let cr = 0; // Default value if condition don't match

if ($w('#input1').value === String(10)) {
  cr = z*10;
}

$w('#text22').text = String(cr);

More: let - JavaScript | MDN

thank you very much for the help, now it worked