Remakers - 3.13 Developing Procedures JS Hacks
Apply your skills to basic procedure development in Javascript.
Q1 (Easy)
Which of these procedures is named wrong, provide a short explanation of justification%%js
function mixIngredients()
// Wrong. This is vague function doIt()
function makeLeftTurn() Explanation Here: __ is right because..
Q2 (Medium)
Finish the code to have a correctly named procedure
%%js
function makeLeftTurn() {
moveForward() ;
rotate180() ;
moveForwardAgain() ;
}
//Todo: add corresponding procedure definitions
function moveForward() {
console.log("Moving forward.");
}
function rotate180() {
console.log("Rotating 180 degrees.");
}
function moveForwardAgain() {
console.log("Moving forward again to complete left turn.");
}
//Run the procedure
makeLeftTurn()
<IPython.core.display.Javascript object>
Q3 (Hard)
Write code to fulfill the requirements Doing a dance! πΊπ Must have
- A shimmy left procedure
- Print
super cool left slide
- Print
- A shimmy right procedure, print
even cooler right slide - Doing a bow to the crowd, print
Great dance!,the audience claps at your bow!
%%javascript
//Code away!
function shimmyLeft() {
console.log("super cool left slide");
}
function shimmyRight() {
console.log("even cooler right slide");
}
function bowToCrowd() {
console.log("Great dance!");
console.log("the audience claps at your bow!");
}
// Call the procedures to perform the dance
shimmyLeft();
shimmyRight();
bowToCrowd();
<IPython.core.display.Javascript object>