How can i Display the 20 elements of sampleArray.? javascript

Display the 20 elements of sampleArray.

Hello and Welcome to the forum!

Your question is a little vague, to say the least :stuck_out_tongue:. However, in JavaScript, You can display anything using the console, like this:

const sampleArray = [1, 2, 3, 4, 5];
console.log(sampleArray);
// Output:  Array(5) [ 1, 2, 3, 4, 5 ]

The output may vary, but should be quite similar.

function kata11 () {
  let result = []
  for (let i=0; i <sampleArray.length;i++){
    if (sampleArray[i]%2===0){
    }
    result += sampleArray[i] + "."
  }

  return result
}

console.log(sampleArray.length); 

thats my code but stilll is not showing what i need

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.

markdown_Forums

You seem to be missing some code here: sampleArray doesn’t seem to exist, you aren’t calling the function anywhere, theres an if block that does nothing in the code, and if you meant first 20 items, the function just returns all the array values in a string with a period between each one and at the end.