Help with a Javascript slideshow I'm trying to do on a project

Hi guys,

I was wondering if you could help me with a project. I’m trying to add a very simple slide show to this website. However I can’t get the Javascript to work for some reason. I’ve included the JS script HTML and CSS below, thanks in advance…

Just skimming through your code, I think you could look at your if/else statements – the conditional statement in brackets () should be written with an equality or strict equality comparator (== or ===).

In terms of doing a deeper dive, could I suggest using codepen as a place to put your code before sharing it? It makes it easy to seperate out your html, css and js and also then for someone to see how it is currently functioning – https://codepen.io/pen/

1 Like

Try using ternary operators in multiple blocks of code. e.g.

`next.onclick = function() {
slideOne.style.display === "inline- block" ? slideOne.style.display === "none" : slideOne.style.display === "inline-block"; 

slideTwo.style.display === "inline-block" ? slideTwo.style.display === "none" : slideThree.style.display === "inline-block";
}`

And so on…
N.B: Make use of a strict equality comparator. It is better when handling heavy code. I purposely only used strict equality comparators in my code example.

1 Like

Thanks man thats really helpful. I thought my code was a bit ‘bulky’

:grinning: