frankcollins3 / fcc-mcsft-cSharp

FreeCodeCamp & Microsoft C# course:
1 stars 0 forks source link

not all paths return value [8:01am] #3

Closed frankcollins3 closed 1 year ago

frankcollins3 commented 1 year ago

attempting to do: create string returning callback functions that take a randomly generated value and return conditionally rendered messages ("Your subscription is ending soon! Renew Now! || Your subscription is ending in {daysUntilExpired}. Renew @ 10% discount"}

error: fixed this already. didn't know. they had to be static strings as well. error CS0236: A field initializer cannot reference the non-static field, method, or property 'Program.random' [/Users/me/Desktop/CsharpProjects/TestProject/TestProject.csproj]

proposed approach: possibly since the else block hasn't been made. keeping issue open since issues keep popping up.

frankcollins3 commented 1 year ago

👍 Screen Shot 2023-09-06 at 8 02 09 AM

compiler seems like it's being silly because every possible case has been covered Screen Shot 2023-09-06 at 8 05 01 AM

// seems that by convention else must be provided if the current block of if code is else if. // even if all possibly cases have been provided return options in a non static function.

[8:06am]

frankcollins3 commented 1 year ago

was hung up because 2 && 3 definitely looked like correct answers. I ended up picking option 3 and failed that question but this very issue was solved by: providing else value in event that else if doesn't have one.

The issue that is returned is "Not all paths return value" Screen Shot 2023-09-06 at 8 12 21 AM

probably missing the edge case a number > 5 or so but moving on. [8:14am]