DEV Community

ViGnEsH
ViGnEsH

Posted on

What is an Array? Simple Explanation with Examples

WHAT IS ARRAY

  • Multiples value store one countries.

  • Looping can't used array because variable different.

  • First variable, all set same name.

  • Array index value go => 0,1,2,3,4,5..., etc.

  • Starting number value zero.

  • Dynamic size - Value change for any time (User).

  • main one is Array symbol []
    square bracket.


    Examples

JavaScript Array program

Couny of Fail


Output

_________________________________Explain about fail count :

  1. First create Array variable name marks and value
  2. Next create variable name fail and second variable name i .
  3. Create While loop in i < less than 5
  4. if condition marks [i] < less than 35 ,i variable name is set because (say in 6 point)
  5. fail variable in post increasesquare bracket i<35 condition true go inside and fail ++ work
  6. i ++ variable also post increase,is 0+1=1, again 1+1=2 again again five time run loop this loop condition fail loop repeat.
  7. The Finally part in Output used console.log (fail) _________________________________ fail and pass count

Output


Explain about fail and pass count :

  1. First create Array variable name marks and value
  2. Next create variable name fail ,pass variable and second variable name i .
  3. Create While loop in i < less than 5
  4. if condition marks [i] < less than 35 ,i variable name is set because say in 6 point
  5. fail variable in post increase
  6. i ++ variable also post increase,this loop condition fail loop repeat.
  7. if condition fail and used of else condition inside pass++ post increase
  8. The Finally part in Output used console.log ("Fail ",fail), console.log ("Pass ",pass) _________________________________

Total of marks

Explain about Total marks:

Output


Explain about Total marks:

  1. Same create Array marks name variable [22,30,12,45,78] this value are sum.
  2. Create two variables (i) let total (ii) let i two value is 0.
  3. Create While loop because now all variable name is same (Explain 6 point )
  4. i < less than 5 this is loop condition
  5. total =total + marks [i] ,what is line i Explain- total value 0 + marks value ex 0+1 =1, 1+1=2,2+1=3,3+1=4 Finally 4+1=5 loop stop because 5 less than 5 fail
  6. The i variable increase in i++ condition, this is a i variable value change for loop runtime (ex)- 0 > 1 > 2 > 3 > 4
  7. Than last step come the Output, used console.log ("Total mark -", total)"" Quotation mark is a string than another topic.

*Array is Dynamic value and different variable store one place used
*

_That's all thank you 😊 _

Top comments (0)