Here is a sample code snippet:
var seats = []
for (a = 0; a <= seatsNumFront; a++) {
seats.push(new Seat((a * xPad) + 300, 60, 30, 30, id++, "A", a, "#998515"))
}
for (b = 0; b <= seatsNumFront; b++) {
seats.push(new Seat((b * xPad) + 300, 100, 30, 30, id++, "B", b, "#998515"))
}
for (c = 0; c <= seatsNumFront; c++) {
seats.push(new Seat((c * xPad) + 300, 140, 30, 30, id++, "C", c, "#998515"))
}
I am looking to make these lines of code execute based on the value I specify.
For example: I want to set a variable and run the code only once according to that variable
So if we write:
var seats = []
var num = 3
for (c = 0; c <= seatsNumFront; c++) {
seats.push(new Seat((c * xPad) + 300, 140, 30, 30, id++, "C", c, "#998515"))
}
Desired output:
var seats = []
var num = 3
for (a = 0; a <= seatsNumFront; a++) {
seats.push(new Seat((a * xPad) + 300, 60, 30, 30, id++, "A", a, "#998515"))
}
for (b = 0; b <= seatsNumFront; b++) {
seats.push(new Seat((b * xPad) + 300, 100, 30, 30, id++, "B", b, "#998515"))
}
for (c = 0; c <= seatsNumFront; c++) {
seats.push(new Seat((c * xPad) + 300, 140, 30, 30, id++, "C", c, "#998515"))
}