Modify the following code to use var, const, and let appropriately. Replace the underlines with either 'var', 'const', or 'let'
constSPEED_OF_LIGHT=299792458varspeedArray=[55,9.8,1000000000,186300]for(leti=0;i<speedArray.length;i++){if(speedArray[i]>SPEED_OF_LIGHT){console.log("Faster than light")}else{console.log("Sub-light speed")}}
What errors will the following code blocks produce? Why?
constfarge={prop1: "one",prop2: "two",prop3: "three"}farge={newProp: "new"};// ANSWER: ERROR! - trying to assign new value to a constnatfarge.prop1="forty-two";// ANSWER: No Error - can alter a object value even with constfarge.propX="ex";// ANSWER: No Error - will add new property to fargedeletefarge.propX;// ANSWER: No Error - allowed to alter objectconsole.log(farge);
Rewrite the following functions using arrow functions