I'm looking to populate an array with values for "name" and "nickname" extracted from an SQLITE database and then display them in an alert box.
This task is part of a JavaScript project developed using Titanium Appcelerator.
Below is the code snippet:
var fightersRS = db.execute('SELECT * FROM fighters');
var setFighters = [];
while (fightersRS.isValidRow())
{
var name = fightersRS.fieldByName('name');
var nickname = fightersRS.fieldByName('nickname');
setFighters.push = {
name: name,
nickname: nickname
};
fightersRS.next();
}
alert(setFighters);
The intended outcome is for the alert to display all values separated by commas, like so:
"muhammad ali, rocky balboa, ten shin han, etc ...."
My current code is not functioning as expected. Any advice on how to achieve the desired output?