GithubHelp home page GithubHelp logo

functions-exercises's Introduction

Functions Exercises

Before you begin

  • Fork and clone this repo to your computer
  • Open vs-code. In the terminal ctrl + j type npm i and press enter
  • Add a file named .gitignore and type in this: node_modules
  • Now the node_modules folder should be greyd out

Congratulations ๐ŸŽ‰

You are ready to begin!


Write your code in the file Exercise.js in the pre-made functions.

  • Commit after each question you solve
  • Do not change any function's name
  • Do not delete any other piece of code, only add yours
  • Do not edit any of the other files
  • Uncomment line 3 if you solved the bonus question

How to run tests?

You can test your code on your own in the Exercise.js file.

But, to pass the task you should also pass the automated tests. You should have 6/6 (you start with 1/6 because of the bonus)

To run the tests type npm test and press enter.



The Questions

Question 1

Write a JavaScript function that reverse a string.

Example x = "Cyber4s;

Expected Output : s4rebyC

Question 2

Write a JavaScript function that generates all combinations of a string.

Example string : 'dog'

Expected Output : d,do,dog,o,og,g

Question 3

Write a JavaScript function that accepts a string as a parameter and converts the first letter of each word of the string in upper case.

Example string : 'the quick brown fox'

Expected Output : 'The Quick Brown Fox '

Question 4

Write a JavaScript function to compute the value of x^n where n is the exponent and x is the bases.

Question 5

Write a JavaScript function to find the first not repeated character.

Sample arguments : 'abacddbec'

Expected output : 'e'

Question 6 - Bonus

Write a JavaScript function which says whether a number is perfect.

According to Wikipedia : In number theory, a perfect number is a positive integer that is equal to the sum of its proper

positive divisors, that is, the sum of its positive divisors excluding the number itself (also known as its aliquot sum.

Equivalently, a perfect number is a number that is half the sum of all of its positive divisors (including itself).

Example : The first perfect number is 6, because 1, 2, and 3 are its proper positive divisors, and 1 + 2 + 3 = 6.

Equivalently, the number 6 is equal to half the sum of all its positive divisors: ( 1 + 2 + 3 + 6 ) / 2 = 6. The next

perfect number is 28 = 1 + 2 + 4 + 7 + 14. This is followed by the perfect numbers 496 and 8128.

functions-exercises's People

Contributors

kosta1221 avatar listguy 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.