The answer is: That the law is valid.
State legislature has the power to banned the sales of the product if the product is proven to endanger the life of people who consume that product.
Even though the negative health effect from junk foods do not occur directly after consumption, it's proven to cause a lot of complications if consumed in the long period of time. Because of this, the ordinance would be considered as valid.