showing results for - "10 6 1 function scope"
Emilia
16 Jan 2018
1/*This function takes a string and returns the result of removing all 
2hyphens, -, from the string*/
3
4function removeHyphens(str) {
5   let strWithoutHyphens = ''
6
7   for (let i = 0; i < str.length; i++) {
8      if (str[i] !== '-') {
9         strWithoutHyphens += str[i];
10      }
11   }
12
13   return strWithoutHyphens;
14}
15
16let launchCodePhone = "314-254-0107";
17console.log(removeHyphens(launchCodePhone));
18console.log(strWithoutHyphens);
19
20
21//3142540107
22/*ReferenceError: strWithoutHyphens is not defined
23(rest of error message omitted)*/
queries leading to this page
10 6 1 function scope10 6 1 function scope