// WORKING CODE [CODE1]
$('.enter-button').on('click', function (e) {
e.preventDefault();
var searchValue = $('.a').val();
var listOfLocations = $('.b').text().trim();
var listSize = $('.b ul li').size();
if (listOfLocations.indexOf(searchValue) === -1) {
switch (listSize) {
case 0:
case 1:
$('.list-left').append('<li>' + searchValue + '</li>');
break;
case 2:
case 3:
$('.list-right').append('<li>' + searchValue + '</li>');
break;
}
}
});
But I want it do this:
// CODE THAT I WANT IT TO RUN [CODE2]
$('.enter-button').on('click', function (e) {
e.preventDefault();
var searchValue = $('.a').val();
var listOfLocations = $('.b').text().trim();
var listSize = $('.b ul li').size();
if (listOfLocations.indexOf(searchValue) === -1) {
switch (listSize) {
case (listSize <= 2):
$('.list-left').append('<li>' + searchValue + '</li>');
break;
case (listSize >= 3):
$('.list-right').append('<li>' + searchValue + '</li>');
break;
}
}
});
Basically I want to run a range case on my switch statement, I looked through other stack overflow questions and they have said to do it like code 2. I haven't been able to get it to work so I'm trying to get some help! Aside from that, I'm also curious on why the case statement doesn't read it like CODE2.