Deploying ReactJS App to Firebase

Step 1: Install Firebase CLI globally

We can check the version by using the following command

Step 2: Login to the firebase account by using firebase CLI

If it is first time then we can navigate to login screen. If already logged in then it will show as “Already logged in “. If you want to login to other account or authenticate again we can use the following command.

firebase login --reauth

Step 3: Initialize firebase in your project’s root directory

firebase init

Then CLI will prompt the following questions.

After proceeding, it will show set of instructions. Navigate through them using Up/Down Arrow keys. Select Hosting by using spacebar.

Now select the project which you want to use. then it shows as “using project your_project_name”. After that you will see the following questions.

firebase.json code should be similar to the following. once check it in your project. if it is missing, rewrites key add it.

Step 4: Build your App using the following command

Step 5: Finally delpoy the App to firebase

Javascript program to find the sum of elements in a sequence up to a given range.

  • From the above program we need to ensure that the range should not exceed the length of the array. If it is exceeding we will assign the range to the array length.
  • Given range is 5. So the sum of first five elements should calculate as 4 + 7 + 6 + 1 + 2 which is equal to 20.

We can also write this program by using slice and reduce methods as follows

  • Here arr.slice(0, range) extracts the elements from 0 to 5. i.e, [4, 7, 6, 1, 2];
  • reduce method starts with an initial value of 0 and adds each number to the accumulator and returns 20 as the output.