[Lua task #06] Make some tests
To work on this, you must have successfully finished the task "[Lua task #05] Perform calculations in Lua"!
This task requires independent learning.
A Scribunto function always returns a string (text) to the Wikipedia page where it is invoked. Lua variables do not have a type, only values have a type. Lua generally tries to convert from one type to another as needed. For example, you can concatenate text with numbers without having to explicitly convert the number to a string first. However, sometimes you have to use the tonumber() function to convert a string to a number.
Lua uses the if <test> then <do-if-true> else <do-if-false> end
structure to pick one of two outcomes depending on whether the test gives true or false.
1 In your module sandbox, amend the function "temperature" to supply 0 as the default if no parameter is supplied. Save it.
2 Write a line in your sandbox to test that. Save it.
3 Make changes to the function "temperature" to store the text you are returning in a variable called "msg". Then return msg
as the last line before the end
of the function. Save it&check in your sandbox that it is still working.
4 Change function "temperature" to test whether the value of "cel" is greater than (>) 9. If it is, then add "It is warm.
" to "msg", otherwise add "It is cold.
" - you'll need the concatenation operator (..) and a construction like msg = msg .. " blah blah"
.
5 Test your function in your sandbox with different values to make sure the test works as expected.