Recap - Array Processor
Part of the Fundamentals section of Coddy's JavaScript journey — lesson 62 of 77.
Challenge
EasyWrite a function named processArray that takes an array of numbers as an argument. The function should do the following:
- Remove the last element from the array.
- Add the number 10 to the end of the array.
- Check if the array includes the number 5. If it does, replace it with the number 50.
- Reverse the order of the elements in the array.
- Return the modified array.
For example:
processArray([1, 2, 3, 4, 5, 6])should return[10, 50, 4, 3, 2, 1]processArray([9, 6, 3, 12])should return[10, 3, 6, 9]
Try it yourself
function processArray(arr) {
// Write code here
}All lessons in Fundamentals
4Operators Part 2
Logical Operators Part 1Logical Operators Part 2Recap - Simple LogicLogical Operators Part 3Type Coercion7Bill Split Calculator
Welcome MessageCalculating The Tip And Total2Variables
NumbersStringBooleanNaming ConventionsEmpty VariablesRecap - Initialize VariablesConstants11Arrays Part 1
Declaring an ArrayAccessing Array ElementsModifying ArraysArray Methods Part 1Array Methods Part 2Recap - Array Processor3Operators Part 1
Arithmetic OperatorsModulo OperatorArithmetic ShortcutsComparison OperatorsStrict vs Loose EqualityRecap - Simple Math6Basic IO
OutputOutput with VariablesType Conversion - Part 1Type Conversion - Part 2Recap - Till 120Recap - True or False