A student wrote this code an is having some problems
//Returns the owner’s username based on a certain rank
// rank (integer) rank show ranks of who had the most followers, used for index
//username(string) username of the owner of that account
function showRank(rank) {
var userList = getColumn(“Most Followed Instagram Accounts”, “Username”);
var username = userList[rank-1];
return username;
}
//can access the average amount of folowers
//average(integer) Average amount of followers
function findFollowerAvg() {
var followerList = getColumn(“Most Followed Instagram Accounts”, “Followers in millions”);
var sum = 0;
for (var i = 0; i < followerList.length; i++) {
sum = sum + followerList[i];
}
var findAverage = sum / followerList.length;
return findAverage;
}
onEvent(“show”, “click”, function( ) {
var user = U7LibrariesProjectPart2_2021.showRank(1);
setText(“text_area1”, user);
});
console.log(U7LibrariesProjectPart2_2021.findFollowerAvg());
showRank(1);
findFollowerAvg(1);
Link to the project or level: [replace with link to the curriculum or get the “Share” link to a project] What I expect to happen: [replace with a detailed description of the behavior you’re trying to create] What actually happens: [replace with a detailed description of what actually happens when the code runs including any errors or unexpected behavior] What I’ve tried: [replace with a detailed description of what you’ve already tried to do to solve the problem]
Please provide the following information to better assist you. Link to the project or level: [replace with link to the curriculum or get the “Share” link to a project] What I expect to happen: [replace with a detailed description of the behavior you’re trying to create] What actually happens: [replace with a detailed description of what actually happens when the code runs including any errors or unexpected behavior] What I’ve tried: [replace with a detailed description of what you’ve already tried to do to solve the problem]
and the following error shows up: ERROR: Line: 16: Oops, we can’t figure out what follwerList is - perhaps you meant the string “follwerList” with quotes? If this is meant to be a variable, make sure you declared a variable: var follwerL
Check the library function. I have copy pasted the code below and bolded the misspelled list name.
//can access the avergae amount of folowers
//average(integer) Average amount of followers
function findFollowerAvg() {
var followerList = getColumn(“Most Followed Instagram Accounts”, “Followers in millions”);
var sum = 0;
for (var i = 0; i < follwerList.length; i++) {
sum = sum + followerList[i];
}
var average = sum / followerList.length;
return average;
}
Ok I see, I looked at the library function code and it is misspelled there… so is that her library or someone else’s she is using? Either way how does she fix the type o?