I'm using forEach to iterate through an array of player names and add in the string ' plays soccer.' to the name. When I use Logger.log, everything appears as expected. Each player name is listed like 'Bob plays soccer.' or 'John plays soccer.'.
However, when I try to put it into a sheet, I only get the last name in the array.
How can I get each name in the list to show up in the sheet itself, specifically using forEach?
I know there are ways to use the standard for loop but I feel like I understand this syntax better whereas with the for loop I really don't understand how it works. Even trying to replicate it from what others have done doesn't make much sense to me. I'm sure I'm missing something dumb and simple, but I can't figure it out.
NOTE: Even when I change the "numRows" to 4, it just repeats "Tim plays soccer." four times. I want each name to show up once.
function forEachTest (){
var players = ['Bob', 'John', 'Mark', 'Tim'];
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var startRow = 1
var startColumn = 1
var numRows = 1
var numColumns = 1
var dataRange = sheet.getRange(startRow, startColumn, numRows, numColumns);
players.forEach(function(eachPlayer) {
Logger.log(eachPlayer + ' plays soccer.');
Logger.log(eachPlayer);
dataRange.setValue(eachPlayer + ' plays soccer.');
});