File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33// Why will an error occur when this program runs?
44// =============> write your prediction here
5- /* - The function will throw a syntax error because we have redeclared the parameter variable "decimalNumber", and we have
6- also used const for declaring percentage, percentage will change when we call the function with different arguments so it should
7- be declared using let.
5+ /* - The function will throw a syntax error because we have redeclared the parameter variable "decimalNumber".
86 - we are console logging the variable decimalNumber outside the function - the variable lives only inside the function
97 */
108
2119
2220// =============> write your explanation here
2321/*I will remove line 14 - a redeclaration of the parameter variable, we will not reassign it, we will get the decimal
24- number by calling the function with an argument and we will console.log the function call*/
22+ number by calling the function with an argument, and we will console.log the function call*/
2523// Finally, correct the code to fix the problem
2624// =============> write your new code here
27- function convertToPercentage ( decimalNumber ) {
28- return `${ decimalNumber * 100 } %` ;
25+ function convertToPercentage ( decimalNumber ) {
26+ decimalNumber = 0.5 ;
27+ const percentage = `${ decimalNumber * 100 } %` ;
28+ return percentage ;
2929}
30+
3031console . log ( convertToPercentage ( 0.5 ) )
You can’t perform that action at this time.
0 commit comments