10.6.1. Function Scope
/*This function takes a string and returns the result of removing all
hyphens, -, from the string*/
function removeHyphens(str) {
let strWithoutHyphens = ''
for (let i = 0; i < str.length; i++) {
if (str[i] !== '-') {
strWithoutHyphens += str[i];
}
}
return strWithoutHyphens;
}
let launchCodePhone = "314-254-0107";
console.log(removeHyphens(launchCodePhone));
console.log(strWithoutHyphens);
//3142540107
/*ReferenceError: strWithoutHyphens is not defined
(rest of error message omitted)*/