Setting of attributes in JavaScript

setAttribute
Задание 1

Given an element:

html<input id="elem">

Set its value attribute to 'text'.

Задание 2

Given an element:

html<input id="elem">

Set its class attribute to 'valid'.