GithubHelp home page GithubHelp logo

js-closures's Introduction

Logo-nav

Kalvium Lab | Create a functionality

Task:

Your task is to create a functionality which can identify whether a number is present in the given array or not. If it is present, then it should return the index of the array of that number, if not then return -1000000.

Starter code

Inside src/app.js file -> arrayOfNumbers and itemToSearch will be already given to you.

Progression 1:

create a global scoped constant NEG_INF with -1000000 value, and a function createPop

Progression 2:

add 2 variables to createPop() : currIndex, check

  1. currIndex -> assign NEG_INF to this variable
  2. check -> assign false to this variable

Progression 3:

create a function searchForElement. Inside this function -> check whether the given item is present in the array or not, if it is present then assign currIndex to the index at which the item is present, and give check a true value, else, if the item is not present -> keep the value of currIndex as NEG_INF and the value for check as false.

Progression 4:

In createPop(), return a function - which uses the updated values of currIndex and check (from searchForElement), in order eturn the following :

  1. If the element is present in the given array -> then display -> The item is present and is at index ${currIndex}
  2. Else, display --> The item is not present and is at index ${currIndex}

Happy Coding Kalvium ❤️

js-closures's People

Contributors

anushkapoonia07 avatar

Watchers

 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.