Skip to content

Instantly share code, notes, and snippets.

View sandrabosk's full-sized avatar
👩‍💻
Always a student, never a master. Have to keep moving forward. ~C.Hall

Aleksandra Bošković sandrabosk

👩‍💻
Always a student, never a master. Have to keep moving forward. ~C.Hall
  • Ironhack
View GitHub Profile
  1. Create a function expression doTheMath(num1, sign, num2)that will return the result of the mathematic operations of num1 operator num2. Allowed operators (signs) are +, -, *, /, %, **. Hint: you can use the switch statement.
  2. Refactor the function in the arrow manner.
  1. Write a function study() that receives one argument (string) and outputs (using console.log()) I am studying ____. after 3 seconds (use setTimeout() and pass as a second argument 3000 (which is 3 seconds)).
  2. Write a second function, chill(), that doesn't receive any arguments and outputs Finished with studying, now chilling..
  3. Using just gained skills, make sure the second function doesn't execute before the first one.
  1. Create a function declaration sayMyName() that receives the string argument and returns The name is ______. Try to invoke this function before it is created (a couple of lines in code before you declare it). Are you able to see the output?
  2. Create a function expression getStudentData() that receives three arguments: name (string), age (number) and city (string) and returns Student ____ (name) is ___ years old and from ______ (city).. Try to invoke this function before it is created (a couple of lines in code before you declare it). Are you able to see the output?
  1. Create a function expression doTheMath(num1, sign, num2)that will return the result of the mathematic operations of num1 operator num2. Allowed operators (signs) are +, -, *, /, %, **. Hint: you can use the switch statement.
  2. Refactor the function in the arrow manner.
  1. Create a function that accepts 3 numbers as parameters, and returs their sum.
  2. Create a function named isNameOddOrEven() that accepts a string as a parameter. The function should return whether a received name has an odd or even number of letters. The expected return should be in the following format - string: ' has an even/odd number of letters'.

Use the given array and iterate over it:

  • using for loop
  • using .forEach() method and show the index of each element next to the element itself.
const fruits = ['apple', 'plum', 'strawberries'];

// for loop
// ... your code here
// Use the given array and perform following operations on it:
const favorites = ['javascript', 'html', 'css'];
// remove first element
// ... your code here
console.log(favorites); // => [ 'html', 'css' ]
// remove last element
// ... your code here
  1. Count from 1 to 50. If number is divisible by 5, it should output IRON, and if number is divisible by 7 it should output HACK. If number is divisible by 5 and 7, it should output IRONHACK. In any other case, it should output number.

  2. Use for...of:

  • Given the iterable let str='hello,dear.friend! nice,to.see you!', replace each dot and comma with space. The final output should be: hello dear friend! nice to see you!.
// Write down what will these statements return:
console.log(true && false); // ==> ?
console.log(11 % 3 === 2); // ==> ?
console.log(false || true); // ==> ?
console.log(!true || false); // ==> ?
console.log(17 == '17'); // ==> ?
console.log(123 === '123'); // ==> ?
let statement = 'I love JavaScript!';
// ************************************************************************************
// https://www.codewars.com/kata/5848565e273af816fb000449/javascript
// Description:
// Encrypt this!
// You want to create secret messages which can be deciphered by the Decipher this! kata.
// Here are the conditions:
// Your message is a string containing space separated words.