- 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 theswitch
statement. - Refactor the function in the arrow manner.
- Write a function
study()
that receives one argument (string) and outputs (using console.log())I am studying ____.
after 3 seconds (usesetTimeout()
and pass as a second argument 3000 (which is 3 seconds)). - Write a second function,
chill()
, that doesn't receive any arguments and outputsFinished with studying, now chilling.
. - Using just gained skills, make sure the second function doesn't execute before the first one.
- Create a function declaration
sayMyName()
that receives the string argument and returnsThe 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? - Create a function expression
getStudentData()
that receives three arguments:name
(string),age
(number) andcity
(string) and returnsStudent ____ (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?
- 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 theswitch
statement. - Refactor the function in the arrow manner.
- Create a function that accepts 3 numbers as parameters, and returs their sum.
- 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
-
Count from 1 to 50. If number is divisible by
5
, it should outputIRON
, and if number is divisible by7
it should outputHACK
. If number is divisible by5
and7
, it should outputIRONHACK
. In any other case, it should output number. -
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!
.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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!'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ************************************************************************************ | |
// 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. |