SBl Posted December 27, 2019 Share Posted December 27, 2019 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 Link to comment Share on other sites More sharing options...
Funce Posted December 29, 2019 Share Posted December 29, 2019 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. Take a look at the JavaScript Functions Reference for more information. Link to comment Share on other sites More sharing options...
SBl Posted December 30, 2019 Author Share Posted December 30, 2019 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. Link to comment Share on other sites More sharing options...
Ingolme Posted December 30, 2019 Share Posted December 30, 2019 The value is being initialized at the beginning of the script. var slideIndex = 1; showSlides(slideIndex); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now