Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Write a function called even that accepts a single number
- as an argument and returns true if the number is even and
- false if the number is odd.*/
- let even = function(n){
- if (n % 2 === 0){
- return true
- }
- else
- {
- return false
- }
- };
- console.log(even(7));
- /*Write a function called squared that accepts a single
- number as an argument and returns the perfect square of the number.
- So squared(5) returns 25 and squared(3) returns 9.*/
- let squared = function(n){
- let exp = Math.pow(n, 2)
- return exp;
- }
- console.log(squared(5));
- /*Write a function called food that accepts no arguments
- and returns an array of your 3 favorite foods.*/
- function food() {
- let food = ['pizza', 'bread', 'chicken']
- return food;
- }
- console.log(food());
- /*Write a function called menu that accepts no arguments and
- returns an object of your 3 favorite foods with the name of
- the foods as keys and the price of each item as the values.*/
- function menu(){
- let menuFoods = {
- cake: 3,
- chicken: 5,
- egg: 1,
- }
- return menuFoods;
- };
- console.log(menu());
Add Comment
Please, Sign In to add comment