Menu
CoddyTech

Recap - Number Processor

Part of the Logic & Flow section of Coddy's GDScript journey. Lesson 65 of 78.

challenge icon

Challenge

Easy

Write a function named process_numbers that takes an array of whole numbers, numbers, and returns a new array:

  1. First drop every number that is 0 or negative.
  2. Then double the even numbers that are left and triple the odd ones.

Keep the original order. Use filter() and map(), and no loop. For example, process_numbers([-4, 0, 5, 2, 8, -3, 7]) returns [15, 4, 16, 21].

The tests call process_numbers() themselves. Do not call it, and do not print anything.

Try it yourself

func process_numbers(numbers: Array[int]):
	# Write code here
	pass

All lessons in Logic & Flow

Practice on your own: Online GDScript compiler