Javascript Excercises v2 v.1
Javascript Excercises v2 v.1
var daysInWeek = 7;
Exercise 2
Write a function echo that also returns the passed parameter. echo('Code Academy') should return 'Code
Academy' and echo('Students') should return 'Students'
Solution:
Exercise 3
Write a function greet having one parameter and returning 'Hello <parameter>!'. greet('Ada') should return 'Hello
Ada!' and greet('Tayo') should return 'Hello Tayo!'.
Solution:
Exercise 4
Solution 1
function hi(name) {
return 'Hi ' + name + '!';
};
Solution 2
Solution:
Exercise 5
Write a function shout that takes a string and returns this string duplicated. In addition, the return should
be logged. The call shout('Fire') should return 'FireFire' and should log 'FireFire'.
Solution:
Exercise 6
Write a function length that takes a string and returns the number of characters of the
string. length('sun') should return 3.
Exercise 7
Create a function that takes two numbers as arguments and return their sum.
Exercise 8
Create a function that takes 4 numbers as arguments and return their sum divided by 2, multiplied by 10.
Exercise 9
Given two numbers, return true if the sum of both numbers is less than 100. Otherwise return false.
Exercise 10
Create a function that takes a number as its only argument and returns true if it's less than or equal to
zero, otherwise return false.
Exercise 11
Write a JavaScript function to test whether the character at the provided (character) index is “a”.
Solution:
Exercise 12
Exercise 13
Write a function to test whether the character at the provided (character) index is upper case
Solution