Answer the question
In order to leave comments, you need to log in
How to display a certain number of elements by condition using foreach?
There is an array, it is displayed through foreach, it is required to display not the entire array but the first 2 elements, in total we will offer 5 of them in the array. I would like to see some example on this topic. Thanks in advance))
Answer the question
In order to leave comments, you need to log in
The cycle then works, but with the logic of calculating the degree of the problem. Look closely at the differences:
var number = 2;
var power = 10;
var result = 1;
for(i = 0; i < power; i = i + 1){
result = result*number;
}
console.log(result);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question