I am surprised no one wrote test code. Sometimes in interviews with challenge this simple and you have access to run ruby they are expecting to see test code. Check out my ruby test code tutorials buds.
I notice lots of people are raising an error instead of ignoring or returning null so they have failed the challenge's instructions.
require"test/unit"# remove the first and last letter of a string# if there is less than 2 characters return zero.defquarteredvalueraiseArgumentError,'Argument is not a string'unlessvalue.is_a?Stringreturnvalueunlessvalue.size>2value[0]=''value.chopendclassQaurteredTest<Test::Unit::TestCasedeftest_quarteredassert_equal'orl',quartered('world'),"quartered('world') should return a string called 'orl'"enddeftest_quartered_ignoreassert_equal'hi',quartered('hi'),"quartered('hi') should return 'hi'"enddeftest_quartered_invalidassert_raise_message('Argument is not a string',"quartered(2) should raise exception")doquartered(2)endendend
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I am surprised no one wrote test code. Sometimes in interviews with challenge this simple and you have access to run ruby they are expecting to see test code. Check out my ruby test code tutorials buds.
I notice lots of people are raising an error instead of ignoring or returning null so they have failed the challenge's instructions.