Home
Javascript Fundamentals
# Javascript basics
# Javascript arrays
# Javascript objects
# Javascript dates
# Javascript Sets
Javascript DOM
# DOM selector methods
# Events and user interactions
# DOM manipulation
# DOM fundamentals
# Recursive functions
Challenge Rush
Random Challenge
// Write a function that takes an array with arbitrary elements and a number as arguments// Return a new array, the first element should be either the given number itself// or zero if the number is smaller than 6// The other elements should be the elements of the original array// Try not to mutate the original array function myFunction ( arr, num ) { return }
return
myFunction([1,2,3], 6)
[6,1,2,3]
myFunction(['a','b'], 2)
[0,'a','b']
myFunction([null,false], 11)
[11,null,false]