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()
function doIt()
I think this one is very vague, and could be improved by being more specific.
function makeLeftTurn()
<IPython.core.display.Javascript object>
Explanation Here: Fuction doIt() is wrong because it is very vague, and could be improved by being more specific.
Q2 (Medium)
Finish the code to have a correctly named procedure
%%javascript
function moveForward() {
console.log("Moving forward.");
}
function rotate180() {
console.log("Turning left");
}
function moveForwardAgain() {
console.log("Moving forward again to complete left turn.");
}
function makeLeftTurn() {
moveForward();
rotate180();
moveForwardAgain();
}
// 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!
//1️ Shimmy left procedure
function shimmyLeft() {
console.log("super cool left slide");
}
//2️ Shimmy right procedure
function shimmyRight() {
console.log("even cooler right slide");
}
//3️ Bow to the crowd procedure
function bowToCrowd() {
console.log("Great dance!");
console.log("the audience claps at your bow!");
}
// Run the dance routine
function doTheDance() {
console.log("🎶 Starting the dance routine...");
shimmyLeft();
shimmyRight();
bowToCrowd();
console.log("🎵 Dance complete!");
}
// Perform the dance!
doTheDance();
<IPython.core.display.Javascript object>