Answers for "add two arrays together"

C#
52

combine two arrays javascript

let arr1 = [0, 1, 2];
let arr2 = [3, 5, 7];
let primes = arr1.concat(arr2);

// > [0, 1, 2, 3, 5, 7]
Posted by: Guest on February-02-2020
1

Concatenate two arrays

Array -- Concatenate two arrays
Write a return method that can concatenate two arrays
 
Solution:
public static int[] concatTwoArrays(int[] arr1 , int[] arr2) {
    int[] result = new int[arr1.length + arr2.length];
    int i = 0;
    for(int each: arr1) {
    result[i] = each;
    i++;
    }  
    for(int each: arr2) {
    result[i] =each;
    i++;
    }
    return result;
    }
Posted by: Guest on September-29-2021
4

concatenate multiple arrays javascript

const array1 = ['a', 'b', 'c'];
const array2 = ['d', 'e', 'f'];
const array3 = [...array1, ...array2];

console.log(array3);
// expected output: Array ["a", "b", "c", "d", "e", "f"]
Posted by: Guest on April-23-2020
0

how to concatenate two arrays

int[] z = x.Concat(y).ToArray();
Posted by: Guest on June-14-2021
0

addition of two arrays

int[] a = {10, 20 30, 40}; int[] b = {25, 50, 75, 100, 125}; int[] sum = new int[b.length];  for (int i = 0; i <= b.length; i++){ 	sum[i] = 0;	 		/*initialize each of the sum values as zeroes, because that's 		what we usually start with*/ 		 	if (i > b.length){  		/*if one array is longer than the other, just add zero the  		remaining elements in the largest array*/ 		sum[i] = b[i] + 0; 	else{ 		sum[i] = a[i] + b[i]; 	} } 
Posted by: Guest on February-03-2021
0

how to concatenate two arrays

var z = new int[x.Length + y.Length];
x.CopyTo(z, 0);
y.CopyTo(z, x.Length);
Posted by: Guest on June-14-2021

Code answers related to "add two arrays together"

C# Answers by Framework

Browse Popular Code Answers by Language