Dear members of the forum, I received a test task of this type. I can not understand a few things:

  • The end result is a certain number of horizontal lines, which in turn consist of individual blocks of different colors?

  • if so, then why specify a color for the objects in the lines array, if it will still be covered with objects from the elements?

  • How best to implement the update color: a separate function through setInterval? There are no ideas yet.

I will be glad to any answer. Thank!

Here is a description of the problem:

“Everyone faced preventive broadcasting on television channels. You need to implement the following task.

You have a set of input data in an object by type:

var params = { lines: [ { background: '#00F', updateTime: 1000, elements: [{ background: '#00F', width: 25 }, { background: '#00F', width: 50 }, { background: '#00F', width: 25 },... ] }... ] } 

Implement the drawing of this data as follows. The entire screen should be filled with elements of the lines array whose width is equal to the width of the screen, and the height of the result of dividing the height of the screen by the number of lines. The color of the line should be taken from the background property.

In each line there are elements whose parameters are taken from the elements array, each element must be drawn with the corresponding width specified in percent, the height equal to the height of the line, and the color from the background property.

Depending on the updateTime property in each row, it is necessary to implement a color change to any other color (it is necessary to implement a color generator), in the time interval the corresponding number of milliseconds specified in the property.

When performing tasks, it is not recommended to use extraneous libraries, frameworks, it is also necessary that the examples work in the same way in the main browsers Chrome, Firefox, IE9 +, Opera "

Closed due to the fact that off-topic participants Kromster , 0xdb , Dmitry Kozlov , Enikeyschik , entithat Jan 18 at 10:18 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • " Learning tasks are allowed as questions only on the condition that you tried to solve them yourself before asking a question . Please edit the question and indicate what caused you difficulties in solving the problem. For example, give the code you wrote, trying to solve the problem "- 0xdb, Dmitry Kozlov, Enikeyschik, entithat
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • According to community rules, questions should not be reduced to completing tasks for students. Give an example of your implementation, add a description of the specific problems you have encountered. - Mikhail Vaysman
  • "So far there are no ideas on this subject" - well, at least one idea is: "a separate function through setInterval" - Igor
  • It seems that the TK was the accountant of the plumbing department who thought that he understood everything. And so the task for an hour maximum, this, along with the invention of tea. - user220409

1 answer 1

It is necessary to implement a repeller epileptic))

  • Yes, the end result is a certain number of horizontal lines, which in turn consist of individual blocks of different colors.
  • I have no idea, but suddenly the width of the elements will be less than 100%? Or more?
  • It is better to implement the color update with a separate function through setInterval, which will be passed through the array. It is better to form an array in advance, and not to go into the DOM every time.

Since this is a test task, you can try all this through OOP to raise prestige in the eyes of the verifier. In general, it seems you understand everything correctly, the matter remains for implementation.