This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getElementsByClassName2(classNameStr) { | |
| const elements = [] | |
| const firstChildren = this.children | |
| function checkChildren(child) { | |
| if (child.classList.contains(classNameStr)) { | |
| elements.push(child) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const parent = document.getElementsByClassName('parent') | |
| // => <div class='parent'></div> | |
| const helloWorlds = document.getElementsByClassName('hello') | |
| // => [ <p class='hello'>hello world 1</p>, | |
| // <p class='hello'>hello world 2</p>, | |
| // <p class='hello'>hello world 3</p>, | |
| // <p class='hello'>hello world 4</p> ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <body> | |
| <div class='parent'> | |
| <p class='hello'>hello world 1</p> | |
| <p class='hello'>hello world 2</p> | |
| <p class='hello'>hello world 3</p> | |
| <p class='hello'>hello world 4</p> | |
| </div> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getElementsByClassName2(classNameStr) { | |
| const elements = [] // the array we will add matching elements to | |
| const firstChildren = this.children // all the children of the element the function is called on | |
| return elements | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class User < ApplicationRecord | |
| has_many :sessions, -> {order "created_at DESC"} | |
| def streak | |
| streak_count = 0 | |
| today = Time.now.to_date | |
| dates_array = self.sessions.map do | session | | |
| session.created_at.to_date |
NewerOlder