How to retreive the lenght of an array? [on hold]

33
December 21, 2018, at 3:30 PM

i try to setup a carousel for a web project i use javascript my code seems to works but i its seem that i can retreive the result of variable or object with the syntax ".this"

i already try to debugg my code with console.log but i see seem the problem come to my syntax i use "this." i don't know how to fix this issue

class Carousel {
    /**
     * @param  {HTMLElement} element
     * @param  {Object} options={}
     * @param  {Object} options.slidesToscroll Nombre d'élement a faire  défilier
     * @param  {Object} options.slidesVisible Nombre d'élement visible dans un slide
     */
    constructor (element, options = {}) {
        this.element = element
        this.options = Object.assign({}, {
            slidesToscroll: 1,
            slidesVisible: 1
        }, options)
        this.children = [].slice.call(element.children)
        let ratio =  this.children.lenght / this.options.slidesVisible
        let root = this.createDivWithClass('carousel')
        let container = this.createDivWithClass('carousel__container')
        container.style.width = (ratio * 100) + "%"
        root.appendChild(container)
        this.element.appendChild(root)
        this.children.forEach((child) => {
            let item = this.createDivWithClass('carousel__item')
            item.style.width =  ((100 / this.options.slidesVisible) / ratio) + "%"
            item.appendChild(child)
            container.appendChild(item)
        })
        console.log ( this.children.lenght)
    }

    /**
     * @param  {string} className
     * @returns  {HTMLElement}
     */
    createDivWithClass (className) {
        let div = document.createElement('div')
        div.setAttribute('class', className)
        return div
    }
}
document.addEventListener('DOMContentLoaded', function () {
    new Carousel(document.querySelector('#caroussel1'),{
        slidesVisible: 3
    })
})

my container should size every item at the same size normaly and on the same line but its doesn't works its display the item one above this other but with different size

READ ALSO
How can I order numerical columns with jQuery “sortElements” plugin?

How can I order numerical columns with jQuery “sortElements” plugin?

I'm using the jQuery script "sortElements" on my tables to sort their columns, but I noticed that the sorting in numerical columns doesn't workThe result of the sorting on them is something like "100 20 250 30"

45
HTML-Angular 6 Stop parent DOM element event from being fired by one of the child elements

HTML-Angular 6 Stop parent DOM element event from being fired by one of the child elements

There were a couple of similar threads - but they are all related to event propagation, but my requirement is somewhat differentHere's my HTML:

25
How to create Biker's Optimize Route for delivering Packages using Nodejs

How to create Biker's Optimize Route for delivering Packages using Nodejs

A Company must deliver the number of packages in City

23