I am working on a content slider for my portfolio page. The goal is to add or subtract 1 from "var state" depending on which button you click.
'var state' increments the display box 1 - 6
- Issue 1: Once 'var state' equals 6, there is no box 7. How can I redefine 'var state' to 1 to restart the rotation? 
- Issue 2: Now the opposite. If 'var state' equals 1 and you click down, there is no box 0. How do I redefine 'var state' to be 6? 
var state = 1;
function currentState() {
    if(state <= 6){
        $("#example"+ state).addClass("selected").show()
        $(".example").not("#example"+ state).hide()
    }
}.example{
    width: 200px;
    height: 50px;
    margin: 10px;
    background: #333;
    color: #FFF;
    font-size: 2em;
}
.hidden{
    display: none; 
}<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<button type="button" onClick="state++;currentState();" id="up">Up</button>
<button type="button" onClick="state--;currentState();" id="down">Down</button>
<div id="example1" class="example">1</div>
<div id="example2" class="example hidden">2</div>
<div id="example3" class="example hidden">3</div>
<div id="example4" class="example hidden">4</div>
<div id="example5" class="example hidden">5</div>
<div id="example6" class="example hidden">6</div> 
     
     
     
     
     
    