Skip to content

Change let to var #64

@jinolacson

Description

@jinolacson

javascript-1/practice.js

Lines 105 to 134 in 3d2c348

let duck = 'cute';
function bathroom() {
let rubberDuck = 'squeaky';
function bathtub() {
let sailorDuck = 'nautical';
}
}
function pond() {
let realDuck = 'fluffy';
}
// There are 4 variables above: duck, rubberDuck, sailorDuck and realDuck
// all within different scopes.
// Given the functions and variables above, edit the arrays
// below to contain only the appropriate variable names
// as strings.
// This array should contain the variable names (as strings) accessible in the global scope.
let globalScope = ['duck', 'sailorDuck', 'rubberDuck', 'realDuck'];
// This array should contain the variable names (as strings) accessible in the bathroom function.
let bathroomScope = ['duck', 'sailorDuck', 'rubberDuck', 'realDuck'];
// This array should contain the variable names (as strings) accessible in the bathtub function.
let bathtubScope = ['duck', 'sailorDuck', 'rubberDuck', 'realDuck'];
// This array should contain the variable names (as strings) accessible in the pond function.
let pondScope = ['duck', 'sailorDuck', 'rubberDuck', 'realDuck'];

Should replace into:

 var duck = 'cute'; 
  
 function bathroom() { 
   var rubberDuck = 'squeaky'; 
   function bathtub() { 
     var sailorDuck = 'nautical'; 
   } 
 } 
  
 function pond() { 
   var realDuck = 'fluffy'; 
 } 
  
 // There are 4 variables above: duck, rubberDuck, sailorDuck and realDuck 
 // all within different scopes. 
 // Given the functions and variables above, edit the arrays 
 // below to contain only the appropriate variable names 
 // as strings. 
  
 // This array should contain the variable names (as strings) accessible in the global scope. 
 var globalScope = ['duck', 'sailorDuck', 'rubberDuck', 'realDuck']; 
  
 // This array should contain the variable names (as strings) accessible in the bathroom function. 
 var bathroomScope = ['duck', 'sailorDuck', 'rubberDuck', 'realDuck']; 
  
 // This array should contain the variable names (as strings) accessible in the bathtub function. 
 var bathtubScope = ['duck', 'sailorDuck', 'rubberDuck', 'realDuck']; 
  
 // This array should contain the variable names (as strings) accessible in the pond function. 
 var pondScope = ['duck', 'sailorDuck', 'rubberDuck', 'realDuck']; 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions