Okay next up..Functions! :(

Describe the difference between declaring a function and calling a function. Give an example in a code snippet using Enlighter.

Functions let us wrap code in reusable packages. Declaring a function is basically naming the function and then consoling the function to do what you put in the parenthesis.

This is how you declare a function:

function doSomething(){ 
console.log("Hello World");

Calling a function is a bit different the function you have declared now has to be told what to do.

This is how you call a function:

function doSomething(){ 
console.log("Go clean up!");
console.log("Go to sleep!");
//this is what calling it would look like
Go clean up!
Go to sleep!

These are the exercises for this week:

function-examples.html / functions-examples.js

scope-example.html / scope-example.js

These are the problem sets:

randomcolor.html / randomcolor.js

game.html / game.js

stairs.html / stairs.js

mountains.html /mountains/js (Not quite finished!)

Join the Conversation

1 Comment

  1. Again really great work. And wrapping your awesome ‘Climbing the Mountain’ solution into a function is easy-peasy. Had to do it because I like it so much!
    function climbTheMountain(phrase){
    let n = phrase.length
    for (let i = 0; i < n; i++){ space = n - i; stair = ' '.repeat(space) + phrase [phrase.length - i - 1]; console.log(stair); } }

Leave a comment

Your email address will not be published. Required fields are marked *