Question: I want to change my css style by JavaScript like i change `transform: rotateZ(120deg)`; 

```
<script>
    var Rotate = ['90deg','120deg','150deg','180deg','210deg','240deg','90deg','120deg','150deg','180deg','210deg','240deg'];
     function Time() {
         var marg, d, hour; 
         marg = document.getElementById("hand");  
         d = new Date(); 
         hour = d.getHours();
         for(i = 0; i < 12; i++) {
             if(hour == i) { 
                 var x=Rotate[i]; 
                 alert(x); 
                 marg.style.transform= "rotateZ(x)";
             }
         }
    }
</script>

```

`alert(x)` is working but `transform` is not working. Is there any way to use array list to change `transform` value?

Answer: 
`"rotateZ(x)"` in your code is a complete string. You need to change it to `"rotateZ(" + x + ")"` to make your code work.

You can use [`Array#forEach`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach) to simplify your task.

```
var Rotate = ['90deg', '120deg', '150deg', '180deg', '210deg', '240deg', '90deg', '120deg', '150deg', '180deg', '210deg', '240deg'];

function Time() {
    var marg, d, hour;

    marg = document.getElementById("hand");
    d = new Date();
    hour = d.getHours();

    Rotate.forEach(function(v, i) {
        if (hour == i) {
            alert(v);
            marg.style.transform = "rotateZ("+ v + ")";
        }
    });
}

```
I know that is beyond your question, but I think the best possible solution to solve the problem is using different css classes and only change the class name in js.

Fiddling with css properties in js seems really unneccessary to me :(