Recap Challenge #3
Lesson 14 of 14 in Coddy's Strings and Arrays in C# course.
To declare an empty array of size n,
int[] newArr = new int[n];Now you can access and modify elements inside the array (as long as it's not exceeding n size):
By default, the array of integers is filled with
0s.
The full syntax is:
type[] arrayName = new type[arraySize];Challenge
MediumWrite a function named combineArrays that gets two arrays of integers, combines them into one, and returns the new array.
For example,
Input: [1, 2, 3], [1, 3, 5]
Expected output: [1, 2, 3, 1, 3, 5]
Try it yourself
using System;
class CombineArrays {
public static int[] combineArrays(int[] a1, int[] a2) {
// Write code here
}
}