js logic