exercise 1 modified for using the js 'dynamic structure'