SOURCE

console 命令行工具 X clear

                    
>
console
// const promises = [3, 2, 1].map(d => (
//     new Promise(resolve => {
//         setTimeout(() => {
//             resolve(d)
//         }, d * 1000)
//     })
// ))
// Promise.race(promises).then((val) => {
//     console.log(val)
// })

// function deleteBlankItems(items) {
//     console.log(items)
//     for (var i = 0; i < items.length; i++) {
//         if (items[i].length == 0) {
//             items.splice(i,1)
//         }
//     }
//     console.log(items)
// }
// var names = ['Rachel','','Meghana', '','','Tim']; 
// deleteBlankItems(names);
// console.log(names)

// const f =n =>n <= 1 ? 1 : n* f (n - 1) ;
// let g = f(4);
// console.log(g)

// let words = ['Hello','World']
// words.forEach((word,i) =>{
// (words[i] = word.split('').reverse().join('')).toLowerCase()})
// console.log(words)

// function hasPosEeg(array) {
//     let hasPos = false
//     let hasieg = false
//     array.forEach(num => {
//         hasPos = num > 0
//         hasNeg = num < 0
//     })
//     return [hasPos, hasNeg]
// }
// console.log(hasPosEeg([-1,0,1]))
// console.log(hasPosEeg([0,1,2]))
// console.log(hasPosEeg([]))
// console.log(hasPosEeg([0,-1,-2]))

// function _(func, items) {
//     let i = 0
//     for (let item of items) {
//         if (func(item)) {
//             items[i] = item
//             i += 1
//         }
//     }
//     items.splice(i)
// }
// console.log(_([1,2,3], [4,4,4]))



// let arrNumber = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]
// let newArrayNumber = Array.from(new Set(arrNumber))
// console.log(newArrayNumber); //[1,2,3,4,5]

// let arrStr = ['a', 'b', 'c', 'a', 'b', 'c']
// let newArrayStr = Array.from(new Set(arrStr))
// console.log(newArrayStr) //["a", "b", "c"]

// let s = "ABAD";
// console.log(s[0]=='A')
// function func(a,b){
//      a=+1;
//      b.push(1)
// }
// const a= 0
// const b= []
// func(a,b)
// console.log(a,b)



function buildWordTreeFromSentences(sentenceList) {
    let root = 0
    sentenceList.forEach(sentence => {
        let base = root
        sentence.split('').forEach(word => {
            if (base[word] == undefined) {
                base[word] = {}
            }
            base = base[word]
        })
    })
    return root
}
console.log(buildWordTreeFromSentences(['Hello world', 'Hello there']))
<div>
<div id="elem1"></div>
<div id="elem2"></div>
</div>
div {
width: 50px;height: 100px;padding : 25px;
}
#elem1 {
box-sizing : border-box ;
background-color: blue ;
}
#elem2{
background-color : red;
}