Skip to content

Instantly share code, notes, and snippets.

@zgulde
Created February 28, 2017 17:19
Show Gist options
  • Select an option

  • Save zgulde/6f2c19ab90a60580b02dd8d6665fda72 to your computer and use it in GitHub Desktop.

Select an option

Save zgulde/6f2c19ab90a60580b02dd8d6665fda72 to your computer and use it in GitHub Desktop.
  1. The following code block is syntactically correct, but will not produce the desired output. What can you change to fix this?

    function sayHello() {
      console.log('Hello, ' + name + '!');
    }
    
    sayHello("Zach");
    
    // desired output: "Hello, Zach!"
  2. The following code block is syntactically correct, but will not produce the desired output. What can you change to fix this?

    function multiply(firstNumber, secondNumber){
      var result = firstNumber * secondNumber;
    }
    
    var answer = multiply(4, 6);
    
    console.log(answer);
    
    // desired output: 24
  3. Write some code that outputs the odd numbers between 1 and 20. Note that there are multiple ways to do this! Provide at least two different solutions.

  4. Write a function that accepts an array and returns the third element in the array.

  5. Write a function that accepts an array of numbers and returns an array of numbers in the original array that are not divisible by 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment