Giter Site home page Giter Site logo

functions-training's Introduction

Lisa Olson - Javascript Functions

Link to repository

https://github.com/lisaolson/functions-training

Summary

I had quite a hard time with these functions. The first few were fairly easy, but still more difficult than I expected. The last one I'm still confused with even after looking at the Solution file. I feel pretty confident writing For loops now and definitely more confident with functions in general, but I need more practice.

1. Build your own concatenation

Return a new string that is the combination of two arguments passed into the function

Example: dog and house will display doghouse

function combineWords(word1, word2) {
	// TODO: Place your code here
}

var result = combineWords('dog', 'house');
console.log(result);
// displays 'doghouse'

2. Repeat a phrase

Display an argument phrase to the console n times

function repeatPhrase(phrase, n) {
	// TODO: Place your code here
}

repeatPhrase("Hello", 5);
// displays
// Hello
// Hello
// Hello
// Hello
// Hello

3. Build your own Power function

Return number power without using built-in Math functions

Example:
45 = 4 * 4 * 4 * 4 * 4 = 1024

function toTheNthPower(number, power) {
	// TODO: Place your code here		
}

var result = toTheNthPower(4, 5);
console.log(result);
// displays 1024

4. Area of a circle: π r2

Return the area of a circle given the radius
background information

function areaOfACircle(radius) {
	// TODO: Place your code here
}

var result = areaOfACircle(2);
console.log(result);
// displays approximately 12.57

5. Pythagorean Theorem: a2 + b2 = c2

Return c given a and b
background information

function pythagoreanTheorem(a, b) {
	// TODO: Place your code here
}

var result = pythagoreanTheorem(3, 4);
conosle.log(result);
// should display 5;

6. Is X Evenly Divisible by Y ?

Return a boolean value whether or not X can be divided by Y without any remainders.

Hint: Explore the world of Modulus operators!

function isXEvenlyDivisibleByY(x, y) {
	// TODO: Place your code here
}

var result = isXEvenlyDivisibleByY(99, 3);
console.log(result);
// displays true

7. Vowel Count:

Return the number of occurrences of vowels in a word. Vowels are a, e, i, o, u, and y

function countVowels(word) {
	// TODO: Place your code here
}

var result = countVowels("stealing");
console.log(result);
// displays 3

Challenge: Can you alter the code to count both upper case AND lower case?

8. Does the array contain "wdi"

Given an array, return true if it contains the string "wdi" and false if it does not contain that string.

Example:

findWdi([9,'Bart Simpson', true, 'wdi']) // returns true
findWdi(['a','b','c']) // returns false
	function findWdi(arr){
		// TODO: Place your code here
	}

9. Build an ASCII Triangle!

Display a simple triangle with asterisks

Example:
printTriangle(5)

*
**
***
****
*****
function printTriangle(length) {
	// TODO: Place your code here
}

printTriangle(3);
// displays
// *
// **
// ***

10. Stretch Challenge: Can you alter the printTriangle function to create a Pyramid?

Example: printPyramid(10);

           *
          * *
         * * *
        * * * *
       * * * * *
      * * * * * *
     * * * * * * *
    * * * * * * * *
   * * * * * * * * *
  * * * * * * * * * *

Warning: This is a surprisingly tricky interview-level exercise. Try at your own risk!

function printPyramid(length) {
	// TODO: Place your code here
}

functions-training's People

Contributors

cofauver avatar bgveenstra avatar lisaolson avatar justincastilla avatar tgaff avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.