I have a list of scores, and I need to display them concisely. How do I read a long row of cells only some of which have scores in them, and print those scores out?

Example: https://docs.google.com/spreadsheets/d/1nPTBFXaIgpruPgNoWFSBUL2yKaibjeNJNExhnHVr8LE/edit#gid=0

I tried using a combination of arrayformula and if's, but failed pretty terribly : )

  • Show what you tried in the body of the question as well include a brief description of your search/research efforts as is suggested in How to Ask. Sep 17, 2020 at 19:20

1 Answer 1


I just ended up writing a script.

Tools > Script Editor

function consolidate(scores) {
  var results = []
  scores[0].forEach(function (score) {
    if (score) return results.push(score)
  return [results]

scores comes in as an array of arrays (in my case one column of n number of rows), and so you have to send it out as such which is why the return [results] results is in brackets.

-Sigh- I love JavaScript.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.