GithubHelp home page GithubHelp logo

js-functionsexerc's Introduction

Functions in JavaScript

Repo containing excercises to practice functions in JS.

Exercises

1. Convert Minutes into Seconds.

Write a function that takes an integer minutes and converts it to seconds.

Examples

convert(5) ➞ 300
convert(3) ➞ 180
convert(2) ➞ 120

2. Return the Next Number from the Integer Passed.

Create a function that takes a number as an argument, increments the number by +1 and returns the result.

Examples

addition(0) ➞ 1
addition(9) ➞ 10
addition(-3) ➞ -2

3. Area of a Triangle.

Write a function that takes the base and height of a triangle and return its area.

Examples

triArea(3, 2) ➞ 3
triArea(7, 4) ➞ 14
triArea(10, 10) ➞ 50

4. Convert Age to Days.

Create a function that takes the age in years and returns the age in days.

Examples

calcAge(65) ➞ 23725
calcAge(0) ➞ 0
calcAge(20) ➞ 7300

5. Power Calculator.

Create a function that takes voltage and current and returns the calculated power.

Examples

circuitPower(230, 10) ➞ 2300
circuitPower(110, 3) ➞ 330
circuitPower(480, 20) ➞ 9600

6. Return Something to Me!.

Write a function that returns the string "something" joined with a space " " and the given argument a.

Examples

giveMeSomething("is better than nothing") ➞ "something is better than nothing"
giveMeSomething("Bob Jane") ➞ "something Bob Jane"
giveMeSomething("something") ➞ "something something"

7. Sum of Polygon Angles.

Given an n-sided regular polygon n, return the total sum of internal angles (in degrees).

Examples

sumPolygon(3) ➞ 180
sumPolygon(4) ➞ 360
sumPolygon(6) ➞ 720

8. Convert Hours and Minutes into Seconds.

Write a function that takes two integers (hours, minutes), converts them to seconds, and adds them.

Examples

convert(1, 3) ➞ 3780
convert(2, 0) ➞ 7200
convert(0, 0) ➞ 0

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.