Advertisement
Guest User

Solution for Challenge "Fix Dom Manipulation Code"

a guest
Jan 20th, 2017
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const laws = document.getElementsByTagName('li');
  2. const indexText = document.getElementById('boldIndex');
  3. const button = document.getElementById('embolden');
  4.  
  5. button.addEventListener('click', (e) => {
  6.     const index = parseInt(indexText.value, 10);
  7.  
  8.     for (let i = 0; i < laws.length; i += 1) {
  9.        let law = laws[i];
  10.  
  11.        // replace 'false' with a correct test condition on the line below
  12.        if (index === i) { // i is the index in the loop
  13.            law.style.fontWeight = 'bold';
  14.        } else {
  15.            law.style.fontWeight = 'normal';
  16.        }
  17.     }
  18. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement