JS lib a like app, which manipulates images (width and rotate). Two ways of doing so, there for two solutions. Changes are applied as inline style.
All features implemented and working.
- Change width
- Rotate image
- Reset applied style
- Version2 Less complex but repetitive code, many functions.
- Version1 More complex, everything is inside one big function. Switch case. Function call done with an object as parameter.
- Object as parameter
- Functions bundled inside object
- Working with switch case
- Instead of using variable, function's return can be used:
for ( var i = 0; i < selector(id).length; i++) {
selector(id)[i].style.width = newWidth
//vs
var element = document.querySelectorAll(id)
for ( var i = 0; i < element.length; i++) {
element[i].style.width = newWidth
}