Skip to content

Instantly share code, notes, and snippets.

@Ingelheim
Created July 13, 2016 15:34
Show Gist options
  • Save Ingelheim/e97760218be6dd28cdf4b5a0983f3e1c to your computer and use it in GitHub Desktop.
Save Ingelheim/e97760218be6dd28cdf4b5a0983f3e1c to your computer and use it in GitHub Desktop.

Exercises

Javascript

  1. What value is now stored in the variable name?
var isKing = true;
var name = isKing ? ‘Arthur’ : ‘Hank’;
  1. What is the difference between == and === in Javascript?

  2. Write a function that takes two numbers as arguments and returns the sum of the two numbers in Javascript

  3. Write a function that takes an array as an argument and prints out the numbers in the array that are greater than 5 (for example foo([3,6,1,7]) would print out 6 and 7) in Javascript

  4. Write a for loop that will iterate from 0 to 20. For each iteration, it will check if the current number is even or odd, and report that to the screen in Javascript

  5. What does 'this' refer to when used in a Java method?

  6. Create an object that has properties with name = "fred" and major="music" and a property that is a function that takes 2 numbers and returns the smallest of the two, or the square of the two if they are equal.

  7. What’s the result of executing this code and why?

function test() {
   console.log(a);
   console.log(foo());
   
   var a = 1;
   function foo() {
      return 2;
   }
}

test();

Ruby

  1. Describe what a class is in Ruby in a few sentences.

  2. Write a function that takes two numbers as arguments and returns the sum of the two numbers in Ruby

  3. What is similar and what is different between the this implementation and the one in Javascript (exercise 3)?

  4. Write a function that takes an array as an argument and prints out the numbers in the array that are greater than 5 (for example foo([3,6,1,7]) would print out 6 and 7) in Ruby

  5. What is similar and what is different between the this implementation and the one in Javascript (exercise 4)?

  6. Write a for loop that will iterate from 0 to 10. For each iteration of the for loop, it will multiply the number by 9 and log the result (e.g. "2 * 9 = 18") in Ruby

  7. Classes

a. Create a Celsius class, that takes the temperature as a parameter.

b. In that same class, define a method that returns the temperature in Fahrenheit. For the conversion we can use the formula temperature*1.8 + 32. Round up the result so it doesn’t contain any decimal values.

c. In that same class, create a to_s method, that returns the Celsius temperature formatted e.g. 16 degrees C

Git

  1. Assume that you created a new file in a project. What would you do to start tracking it under git (let's assume that the direktory you are currently in already exists)?

  2. In the morning, what would you do to make sure you have the most current git branch on your local machine?

Command line

  1. How would you create a new folder named 'new_folder' in the command line?

  2. Assuming you created that folder, how would you access that folder using the command line?

HTML

  1. What is an 'ul' and an 'ol' in HTML? What are the similarities and differences?

  2. What is the HEAD and BODY in HTML? What would both contain?

  3. How would you require a javascript file (for instance test.js, which is on the same level as the HTML) in HTML?

  4. How qould you require a css file (for instance test.css, which is two level deeper as the HTML) in HTML?

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