JavaScript Shorcut to storing incremented values in array?

this is my code currently:

let array = [`1 (1).jgp`,`1 (2).jgp`,`1 (3).jgp`,`1 (4).jgp`,`1 (5).jgp`,`1 (6).jgp`,`1 (7).jgp`,`1 (8).jgp`,`1 (9).jgp`,`1 (10).jgp`,`1 (11).jgp`]
//rest of the code

Is there a more efficent way of storing the data?

I have tried:

for (i = 0; i < 12; i++) {
    let array = [`1`+(i)+`.jgp`]
};
//rest of the code

But, then when I tried to call array it returned: Uncaught ReferenceError: array is not defined at :1:1

I also tried:

let array = [`1`+(i = 0; i < 12; i++)+`.jgp`]
//rest of the code

But that returned: Uncaught SyntaxError: Unexpected token ;

Please let me know what I'm doing wrong? Or how I can make this code more efficient. Thanks,

Answer:1

You can generate the array using Array#from:

const arr = Array.from({ length: 10 }, (_, i) => `1 (${i + 1}).jgp`);

console.log(arr);
Answer:2

Is there a more efficent way of storing the data?

You mean store in such a way that less storage is required?

Store in this format

var arrayObj = {
  template : "{{i}} ({{i}}).jgp",
  startIndex : 1,
  endIndex : 10
};

Or how I can make this code more efficient.

If how much storage is used is not the concern, then simply use a simple iterator

var array = [];
for( var counter = 1; counter <= 10; counter++ )
{
  array.push(  "1 ( " + counter + " ).jgp" );
}
Answer:3

How to set value for input="color" when typing in input(.color-scheme__log-input-text), for example if I type #060606 - this color have to be applied to input="color" как изменить цвет input="color" ...

How to set value for input="color" when typing in input(.color-scheme__log-input-text), for example if I type #060606 - this color have to be applied to input="color" как изменить цвет input="color" ...

  1. value input color
  2. input value color css
  3. input value color change
  4. input value color html
  5. set value input color
  6. value input type color
  7. change input value color css
  8. input value text color
  9. input value font color
  10. change input value color jquery
  11. bootstrap input value color
  12. input value background color
  13. jquery input value color
  14. change input value color using jquery
  15. input value default color
  16. input color value rgb
  17. javascript change input value color
  18. get value of input color jquery
  19. get value of input color
  20. input color value not working

I am pretty new in Angular 2. I am studying how to create modules into an Angular app and I have the following doubt related a tutorial that I am following. My doubt is related to the routing. So in ...

I am pretty new in Angular 2. I am studying how to create modules into an Angular app and I have the following doubt related a tutorial that I am following. My doubt is related to the routing. So in ...

  1. what exact meaning of love
  2. what is the exact meaning of crush
  3. what is the exact meaning of ego
  4. what is the exact meaning of attitude
  5. what is the exact meaning of dating
  6. what is the exact meaning of crush in hindi
  7. what is the exact meaning of life
  8. what is the exact meaning of lol
  9. what is the exact meaning of virgin
  10. what is the exact meaning of peer tutoring
  11. what is the exact meaning of civilization
  12. what is the exact meaning of bae
  13. what is the exact meaning of democracy
  14. what is the exact meaning of memorial day
  15. what is the exact meaning of merry christmas
  16. what is the exact meaning of science
  17. what is the exact meaning of crush in tamil
  18. what is the exact meaning of global warming
  19. what is exact meaning of serverless computing in cloud
  20. what is the exact meaning of corruption

I searched a lot on the internet but I still can't find the right answer to my question. I am trying to "print" all the selected values out of multiple checkboxes on my html-page. However, this works ...

I searched a lot on the internet but I still can't find the right answer to my question. I am trying to "print" all the selected values out of multiple checkboxes on my html-page. However, this works ...

  1. multiple values checkboxes
  2. multiple checkbox values in php
  3. multiple values checkbox html
  4. multiple values checkbox jquery
  5. multiple checkbox values in javascript
  6. multiple checkbox values in angular 5
  7. multiple checkbox values in angularjs
  8. multiple checkbox values in servlet
  9. multiple checkbox values in jsp
  10. multiple checkbox values in angular 6
  11. multiple checkbox values angular
  12. multiple checkbox values in mysql
  13. multiple checkbox values excel
  14. multiple checkbox values codeigniter
  15. multiple checkbox values get
  16. multiple checkbox value get in jquery
  17. multiple checkbox value insert in php
  18. multiple checkbox value insert in codeigniter
  19. multiple checkbox value get in php
  20. multiple checkbox value insert update and delete in php

I've got this object variable: var Background = { x: 0, y: 0, speed: 4, initialize: function (x, y){ this.x = x; this.y = y; move: ...

I've got this object variable: var Background = { x: 0, y: 0, speed: 4, initialize: function (x, y){ this.x = x; this.y = y; move: ...

  1. object variables array javascript
  2. object array variable
  3. ssis object variable array
  4. object variable inside array
  5. php object array variable
  6. powershell variable object array
  7. static variable object array
  8. javascript declare object array variable
  9. ssis object variable string array