Home › Forums › JavaScript › If statment in slider function to loop to start? › Reply To: If statment in slider function to loop to start?
Thanks guys
@Shikkediel Thank you, I thought that might be the case, I bumbed into that concept when declaring if statements before variables to try and get round codecademy bugging out.
@shaneisme Thanks, I really wasn’t expecting that much :D
I get the DRY premise, I watched Chris’ Modern Web Designer’s Workflow presentation. I’m so new that I’m not even aware I could/would need to reuse that code.
I have one question based on what you’ve done and one that came up from really examining the code to while trying and figure out what you did.
- Why do you need to return an object? I take it the
slides.currentSlide
line selects thegetSlider()
function then thecurrentSlide
variable within the function? Or is it selecting the returned object? I don’t know what ‘returning’ an object is or does yet, I’m just not sure why you need to do it if the above line references thecurrentSlide
variable. - In the if statements it checks if both the
prevSlide
andnextSlide
variables are equal to 0. Now is this referencing the DOM order? 0 being the end of available HTML elements within that selection and it would depend if you are moving.next()
or.prev()
. 0 for.next()
would be slide 4 and 0 for.prev()
would actually be slide number 1?
I hope that makes sense. I don’t want to pester you with annoying questions, I just couldn’t find any explanation for my questions that I could yet understand in the jQuery or w3Schools documentation.
Thanks again
porgeet