I've just started learning solidity and I tried to make a contract in which you are able to add names to Santa's naughty or nice list, and I want to be able to enter a name and I want the output to be whether the name is on the naughty or nice list or doesn't exist. Here I just tried to see if the inputed name is in the Naughty list and it was giving me the error message: Undeclared Identifier. I get this error in the place highlighted in the last function, thank you to anyone that helps.
pragma solidity ^0.8.11;
contract SantaList {
struct NaughtyList{
string badBoy;
uint position;
}
struct NiceList{
string goodBoy;
uint position;
}
NaughtyList[] public badNames;
NiceList[] public goodNames;
uint internal nextPosition = 1;
function AddToBadList(string memory badBoy) public{
badNames.push(NaughtyList(badBoy, nextPosition));
nextPosition++;
}
function AddToNiceList(string memory goodBoy) public{
goodNames.push(NiceList(goodBoy, nextPosition));
nextPosition++;
}
function GetNaughtyList() view public returns(NaughtyList[] memory){
return badNames;
}
function GetNiceList() view public returns(NiceList[] memory){
return goodNames;
}
function CheckList(string memory name) public {
for(uint i = 0; i < badNames.length; i++){
if(badNames[i].badBoy == **badBoy**){
return **badBoy**;
return " is on the naughty list";
}
}
}
}