96.2k views
1 vote
Consider this program on the picture attached:

(a) In what programming language is this program implemented?
(b) Why is this program correct? In other words, how does it work?
(c) In what way is the program poorly designed?

Consider this program on the picture attached: (a) In what programming language is-example-1
User SlavaSt
by
5.1k points

1 Answer

4 votes
a) javascript (or Ecmascript if you’re fancy like that)

b) the program assigns the immutable variable “arr” to an array of intagers. It then iterates over the items of the array starting at index zero. The current value is declared as “item”. It will then print item cast as a string to the console.

c) this program is poorly designed due to the use of “SetTimeout”. During each iteration, the program will await item milliseconds before printing the item to the console. This affects the speed of the program due to thread sleeps every iteration
User PriceCheaperton
by
4.7k points