This might have to do with me updating Meteor this morning.
Anyway here is some code:
//this returns Words properly
console.log('splitter', splitSentenceIntoWordsForward(sentence))
var wordsForward = splitSentenceIntoWordsForward(sentence)
//if I remove this line then everything works.
UserSentences.insert({user: Meteor.userId(), words: wordsForward})
//If I don't remove the line above, this prints an array of empty objects like this: [ { }, { } ]
console.log("wordsForward new", wordsForward, JSON.stringify(wordsForward))
It appears that insert is destroying the objects in the array somehow.
My original code has been working for weeks. Only this morning has it stopped. (There are other things besides meteor update that could be involved. I have added simpleschema and collection2. I also change some publish methods, but this code is fully run on the server.
This should work and I think the lack of response is because of that plus there must be something else going on. You need to dissect more: Does the UserSentences collection get inserted with the expected document? Have you tried simplifying the problem (just create a static array of two objects, insert it into UserSentences, and see if it’s changed after)? create a new, different collection and use that instead? Lift it out of your application environment - does that then work? Make wordsForward a const, what happens then?