Complete the code to declare an enum named Color with values Red, Green, and Blue.
[1] Color {
Red,
Green,
Blue
}In blockchain languages like Solidity, enum is used to declare an enumeration type.
Complete the code to assign the enum value Green to the variable favoriteColor.
Color favoriteColor = Color.[1];To assign an enum value, use the enum type name followed by a dot and the value name.
Fix the error in the code to correctly compare if the variable currentStatus equals Status.Active.
if (currentStatus [1] Status.Active) { // do something }
= which assigns instead of compares.=> which is not a comparison operator.Use == to compare enum values for equality.
Fill both blanks to create a function that returns true if the input status is Pending.
function isPending(Status status) public pure returns (bool) {
return status [1] Status.[2];
}The function compares the input status with Status.Pending using the equality operator ==.
Fill all three blanks to create a mapping from address to Status and a function to set the status.
mapping(address => Status) public [1]; function setStatus(address user, Status newStatus) public { [2][user] = [3]; }
newStatus.The mapping is named userStatus. The function sets userStatus[user] to newStatus.