# The "n" in function showSlides(n)?

## Recommended Posts

Hello,

as a relative new beginner I don't get a full understanding of the working of this functions below concerning the creation of a Slideshow (https://www.w3schools.com/howto/howto_js_slideshow.asp ).

Especially how the "n" is initially defined: what is the first value for n in this example? In the function showSlides(n) there is the IF-request: if (n > slides.length ….) - but what is the value for n at this Point? I can't find any start value for this n line n = 1 - so how can IF decide this comparison?

Thanks

##### Share on other sites

n is a parameter passed when the showSlides function is called. It evaluates to whatever is put inside the function call,  for instance:

`showSlides(3);`

Would give the value of n to be three.

##### Share on other sites

thanks - yes, I understand that n is the Parameter in that function - the Point is: in the whole Code for that slide nowhere n is getting any value - there is never defined any concrete value for that n e. g. showSlides(3) like in your example - so how compare that n in the IF-Question? n must have a value - I know - otherwise this script wouldn't work, but I can't figure out where it comes from.

##### Share on other sites

The value is being initialized at the beginning of the script.

```var slideIndex = 1;
showSlides(slideIndex);```

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.