Guys, more for the beginners/middle range guys here - but here is a series of interactions i did with ChatGPT that ended up with a great result and what looks like pretty good code to me
This took almost no time - other than cutting and pasting the results and then doing a deploy each time to check
Its quite unbelievable how forgiving it is and also how well it allows you to drill down on a problem through a series of steps rather than having to know it all at the start
Very informative and the description of what each of the code segments does is quite informative - a good tool to send beginners to when they ask some basic question - and something that would give code that is quite similar each time
It is better to use const or let as appropriate, as it allows the interpreter to generate more efficient code and will trap some bugs that might otherwise get through.
const MyArrayOfArray = [
[1,2,3],
[4,5,6],
[7,8,9]
]
for(var i = 0;i<MyArrayOfArray.length;i++) {
const Collection = MyArrayOfArray[i]
/* The below will also increment our first for loop (i is global) - Not good */
for(var i = 0;i<Collection.length;i++) {
...
}
}
for(let i = 0;i<MyArrayOfArray.length;i++) {
const Collection = MyArrayOfArray[i]
/* This wont */
for(let i = 0;i<Collection.length;i++) {
...
}
}