JavaScript exercises and various functions