Giter VIP home page Giter VIP logo

javascript-training's Introduction

Hi there ๐Ÿ‘‹

Screenshot

Jyoti is an ambitious problem solver with a passion to learn and spread knowledge. She has experience in web development and possesses great communication people relationship skills. She is thorough and precise in everything she does and has keen interest in technology, web applications and user experience.

javascript-training's People

javascript-training's Issues

javascript training Basic...

Basic JavaScript: Replace Loops using Recursion
Recursion is the concept that a function can be expressed in terms of itself. To help understand this, start by thinking about the following task: multiply the first n elements of an array to create the product of those elements. Using a for loop, you could do this:

function multiply(arr, n) {
var product = 1;
for (var i = 0; i < n; i++) {
product *= arr[i];
}
return product;
}
However, notice that multiply(arr, n) == multiply(arr, n - 1) * arr[n - 1]. That means you can rewrite multiply in terms of itself and never need to use a loop.

function multiply(arr, n) {
if (n <= 0) {
return 1;
} else {
return multiply(arr, n - 1) * arr[n - 1];
}
}
The recursive version of multiply breaks down like this. In the base case, where n <= 0, it returns 1. For larger values of n, it calls itself, but with n - 1. That function call is evaluated in the same way, calling multiply again until n <= 0. At this point, all the functions can return and the original multiply returns the answer.****

JavaScript challenges

@jyoti-wp
Please complete these exercises:

  1. Create a file called challenge.js in your html directory.
  2. Include this javascript file in your index.html, just before ends, like so:
    <script src="challenge.js"></script>
  • Exercise 1: Write a variable called age and its value should be 60;

  • Exercise 2: Write an if, else condition, that should console.log( 'old' ); if the value of age variable is greater than 50, else it should console.log( 'not old' );

  • Exercise 3: Create a variable called day whose value should be 'Saturday', then 'Write a function that console.log('weekend'); if the value of day is 'Saturday' or 'Sunday'

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.