给出两个数组,A和B,每个数组都包含整数.找到A和B中出现的所有整数,然后返回一个包含它们的新数组.
给出一个问题场景, 开发一个算法解决方案.
Follow these step-by-step instructions to develop an algorithmic solution to this problem.

1. Begin by initializing an empty array called result to hold the final answer.

2. Next, loop through array A.

3. For each element in array A, check if it is present in array B. One way to do this is to use the `includes` method.

4. If the element from array A is present in array B, add it to the result array.

5. Once the loop is done, you will have compared all elements in array A with all elements in array B.

6. Return the result array, which contains only the elements that appear in both array A and B.

Here's a possible implementation, in JavaScript.

```javascript
function findCommonElements(A, B) {
  var result = []; 
  for (var i = 0; i < A.length; i++) {
    if (B.includes(A[i])) {
      result.push(A[i]);
    }
  }
  return result;
}

```

This algorithm would return a new array containing all the integers that appear in both arrays A and B.