dingdongDITCH
kata idea
by trentHarlem
HTML
<h1>
dingdongDitch
</h1>
<div id='target'>
</div>
JavaScript
const target= document.querySelector('#target')
const myBlock = ['doorbell1', 'doorbell2', 'doorbell3', 'doorbell4']
const dingDong = (a) => a.map((item,i) => a.map(item =>((a.indexOf(item)!==i)?item:'Ditch!')))
//a.reduce((arr,item,i) => a.map(item =>((a.indexOf(item)!==i)?arr:'Ditch!')),[])
/* const dingDong = (a) => {
const houses = []
a.map(item => {
houses.push(a.map((item,i)=>(a.indexOf(item)!==i)?item:'Ditch!').join(' '))
//newZoot.push((myArr.indexOf(item)!==i)?item:'Ditch!')
//console.log(a.indexOf(item),item,i)
})//map
return houses
}//ditch */
//const test = dingDong(myBlock)
//target.innerHTML+=`${test}`
target.innerHTML+=`${dingDong(myBlock)}`
console.log(dingDong(myBlock))
/* function wave(str) {
const arr = []
const split = str.split('')
for (let i = 0; i < str.length; i++) {
let cap = str[i].toUpperCase()
//arr.push(i,str.replace(str[i],cap))
arr.push(split.slice(i,i+1,'poo'))
}
return arr
}
// .slice(i,1,cap).join('')
console.log(wave('hello'))
*/
// defining a custom Array (method)
/* Array.prototype.minusOne = function() {
const arr = [];
console.log(this === myArray)
for (const x of this) {
arr.push(x-1)
}
return arr
} */
///////////////////////////////
/* arr.forEach(function(item) {
console.log(this === window); //false
console.log(this === arr); //true
},arr); */
/*
Array.prototype.philter = function(func) {
const arr = [];
console.log(this === myArray)
for (const x of this) {
if (func(this[x])) {
arr.push(this[x])
}
}
return arr
}
const greaterFive = x => x > 5
const myArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
const philtered = myArray.philter(greaterFive)
console.log(philtered)
console.log(myArray.minusOne())
*/