Array name | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Array name

Can we change the name of an array from arr to anything else?

28th Aug 2017, 1:40 PM
shreyansh khaitan
shreyansh khaitan - avatar
3 Answers
+ 4
It's how you create it. Variables can have any name.
28th Aug 2017, 1:42 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 4
like if there's already an array named arr, you wanna create an array called rando, just set the value of rando to arr.
28th Aug 2017, 1:42 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
0
You can name them however you need to. If I had an array of all the classes I'm taking I could name it currentClasses, or myClasses, or whatever else I wanted. Now say I had another array with the list of my teachers I could call it myTeachers, or currentTeachers. Whatever helps you recognize what the array is for. If I named my array of teachers Hrjfoebt, that would technically work, but it wouldn't be easy to remember, or type a lot of times. The general naming convention for arrays is to name it something meaningful, that way if someone else looks at your code they can tell what's in the array just by reading the name. It's also standard to make the first word lowercase, and any other words title case. likeThisExample This is called Camel-case, and just helps to make it easier to read at a glance. readingthissentence is harder than readingThisSentence.
28th Aug 2017, 2:49 PM
Dakota Mullins
Dakota Mullins - avatar