how to get 1 elements in foreach javascript code example Example: mdn foreach arr.forEach(callback(currentValue [, index [, array]])[, thisArg])