GithubHelp home page GithubHelp logo

array-practice-1's Introduction

Array practice

Complete the following exercises to improve your understanding of arrays in javascript!

Instructions:

  • In main.js, define the functions listed below and test that it works by running it against helper.test(yourFunction(), yourExpectedValue). To run the test, run node main.js in your terminal
  • As opposed to manually checking the output every time you run the function, we've written a helper method (helper.test()) to help you check whether your code produces the expected output.
  • For each function, add 1-2 more test cases to confirm that your function really works.

Exercises:

  1. Write a JavaScript function which accept a number as input and insert dashes (-) between each two even numbers.
  • Sample input: 025486
  • Sample output: 0-254-8-6
  1. Write a Javascript function to find the most frequent item of an array. It should return a string denoting the item and the number of times it occurs in the array.
  • Sample input: [3, 'a', 'a', 'a', 2, 3, 'a', 3, 'a', 2, 4, 9, 3];
  • Sample output : 'a (5 times)'
  1. Write a Javascript function to remove duplicate items from an array (ignore case sensitivity).
  • Sample input : [1, 'a', 'A', 'b', 2, 2]
  • Sample output: [1, 'a', 'b', 2]
  1. Write a Javascript function to compute the union of two arrays.
  • Sample input: union([1, 2, 3], [100, 2, 1, 10])
  • Sample output: [1, 2, 3, 10, 100]
  1. Write a JavaScript function to merge two arrays and removes all duplicates elements.
  • Sample input: mergeArray([1, 2, 3], [2, 30, 1])
  • Sample output: [3, 2, 30, 1]

array-practice-1's People

Contributors

davidtan-tw avatar davified 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.