FastPrepConvert a Restricted Function to an Arrow Function
Problems/Convert a Restricted Function to an Arrow Function

Convert a Restricted Function to an Arrow Function

Walmart logoWalmart● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The named task of turning a regular function into an arrow function matches at about 55%. The report gives no original function or output. The one-parameter arithmetic grammar, the promise that input is valid, one fixed form of output, the excluded contexts and the limits are our choices. The exercise changes text within that grammar. It does not claim a general JavaScript conversion. We wrote all the complete examples.

You are given source, a JavaScript function declaration. Turn it into the arrow-function string described below.

The input has this shape: function NAME(PARAM) { return PARAM OP INTEGER; }

  • NAME and PARAM are different identifiers made of lowercase ASCII letters only. Neither is a reserved word.
  • The same parameter appears in the parameter list and in the return expression.
  • OP is exactly +, - or *.
  • INTEGER is a nonnegative whole number from 0 through 999 in canonical decimal form: no leading zeroes, except for the number 0 itself.

Whitespace here means only ASCII space, tab and newline. It may appear around the declaration or between tokens. There is at least one whitespace character between function and NAME, and between return and PARAM. Everywhere else, punctuation may touch the tokens next to it with no space.

Return exactly const NAME = (PARAM) => PARAM OP INTEGER;, with one ASCII space at each space shown and no whitespace at the start or end. Keep the name, parameter, operator and number text as they are. Do not run the code or change the input.

The input holds only this one pure return expression. It has no calls, comments, strings, nested statements, this, arguments, super, async or generator functions, or caller context that depends on constructors or declaration hoisting.

Function

convertRestrictedFunctionToArrow(source: String) → String

Examples

Example 1

source = "function add(x) { return x + 1; }"return = "const add = (x) => x + 1;"

Keep the name add, the parameter x and the addition, and write them in the exact arrow form.

Example 2

source = "function lower(value){return value-999;}"return = "const lower = (value) => value - 999;"

Here punctuation touches the tokens with no spaces. The output still has every space the arrow form requires.

Example 3

source = "\tfunction\nscale ( amount )\n{\treturn\tamount*0 ;\n}\t"return = "const scale = (amount) => amount * 0;"

The input uses spaces, tabs and newlines as separators. They all become the fixed spacing of the output. Multiplying by zero is not simplified: it stays in the output as written.

Constraints

  • 1 <= source.length <= 200, counted in ASCII characters.
  • source is a valid declaration that follows the shape and the input rules in the statement.
  • 1 <= NAME.length, PARAM.length <= 10. Names contain only a through z, are different from each other, and are not reserved JavaScript keywords.
  • Whitespace characters have ASCII codes 32, 9 and 10.
  • INTEGER is 0, or a decimal number of one, two or three digits starting with 1 through 9.

More Walmart Phone Screen questions

  • Count Months Starting on SundayPHONE SCREEN · Seen Aug 2026
  • Longest Even-Length WordPHONE SCREEN · Seen Aug 2026
  • Range ModulePHONE SCREEN · Seen Aug 2026
  • Meeting Rooms IIPHONE SCREEN · Seen Aug 2026
  • Sort Real Number StringsPHONE SCREEN · Seen Jan 2026
  • Check a Password Against a Supplied PolicyPHONE SCREEN · Seen Jun 2025
  • Repair One Missing Function Punctuation CharacterPHONE SCREEN · Seen Jun 2025
  • Can the Singer Perform the Song?PHONE SCREEN · Seen Mar 2025
  • Rooms With Two Other Entrances and a Treasure SuccessorPHONE SCREEN · Seen Mar 2025
  • First Dictionary Word from Note LettersPHONE SCREEN · Seen Aug 2022

Similar questions at other companies

  • Run-Length Encoding and DecodingAirbnb · PHONE SCREENAirbnb interview questions
  • Straight-Line Word SearchReddit · PHONE SCREENReddit interview questions
  • Search and Format ContactsAdyen · PHONE SCREENAdyen interview questions
  • Subtract Two Large Number StringsStackAdapt · PHONE SCREENStackAdapt interview questions
  • Transaction Fee Calculator — Parts 1–2: Basic Fee Calculation and Conditional Fee RulesStripe · PHONE SCREENStripe interview questions
  • Valid ParenthesesByteDance · PHONE SCREENByteDance interview questions
  • Detect a Straight FlushTemu · PHONE SCREENTemu interview questions
  • Check if a String Is a PalindromeCisco · PHONE SCREENCisco interview questions
  • Halfway Course in a Single TrackCrunchyroll · PHONE SCREENCrunchyroll interview questions
  • Longest Common PrefixKotak Mahindra Bank · PHONE SCREEN · ONSITE INTERVIEWKotak Mahindra Bank interview questions
All Walmart interview questionsSee Walmart hiring insights
Saved
class Solution {
    public String convertRestrictedFunctionToArrow(String source) {
        // Write your code here.
        return "";
    }

}
Checking account…