Skip to content

Instantly share code, notes, and snippets.

@Akifcan
Created May 4, 2022 10:20
Show Gist options
  • Save Akifcan/3be2761d10c152c334903df20030b944 to your computer and use it in GitHub Desktop.
Save Akifcan/3be2761d10c152c334903df20030b944 to your computer and use it in GitHub Desktop.
Missing Number
const profile = {
name: 'peter',
age: 55,
kids: [{
name: 'jil',
age: 23
},
{
name: 'peter',
age: 1
},
{
name: 'bill',
age: 2
},
]
}
const x = profile.kids.map(kid => kid.age).reduce((total, current) => total += current, profile.age)
const questions = []
function createQuestion(max) {
const number1 = Math.floor(Math.random() * 10) + 1
const number2 = Math.floor(Math.random() * 10) + 1
const answer = number1 + number2
if (answer > max) {
return createQuestion(max)
}
questions.push({
number1,
number2,
answer
})
}
while (questions.length < 5) {
createQuestion(10)
}
function sum(x) {
return function(y) {
return y ? sum(x + y) : x
}
}
const numbers = [1, 2, 4, 5, 6, 7, 8, 9]
console.log(numbers)
for (let i in numbers) {
if (numbers[+i + 1]) {
if (numbers[i] - numbers[+i + 1] !== -1) {
const difference = Math.abs(numbers[i] - numbers[+i + 1])
const missings = []
for (let x = 1; x < difference; x++) {
console.log("missing is" + parseInt(numbers[i]+x))
}
break
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment