FastPrepRepair One Missing Function Punctuation Character
Problems/Repair One Missing Function Punctuation Character

Repair One Missing Function Punctuation Character

Walmart logoWalmart● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The named JavaScript syntax-repair task matches at about 45%. The report gives no original snippet or bug. The narrow declaration grammar, one missing punctuation character, the rule for joined names, one unique and standard repair, the output spacing and the limits are our choices. We wrote every complete test case. The task does not rebuild a specific bug from the report or repair any JavaScript.

You are given source, a short JavaScript function declaration with exactly one punctuation character missing. Put the missing character back and return the repaired declaration.

The full declaration 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 return expression uses the same parameter, PARAM.
  • OP is exactly +, - or *.
  • INTEGER is a whole number from 0 through 999 in canonical decimal form: no leading zeroes, except for the number 0 itself.

The missing character is one of (, ), {, } or ;. Every identifier, keyword, operator and digit is still there, unchanged. If the missing character is the opening parenthesis, the name and the parameter can run together into one word. The parameter after return must still match, and that tells you how the repair must look.

Whitespace here means only ASCII space, tab and newline. The full declaration has whitespace between function and NAME, and between return and PARAM. Everywhere else, whitespace is optional: between other tokens and around the whole declaration. Putting the missing character on either side of some whitespace can give the same output once the output spacing is applied. The input always has exactly one valid repair after the output spacing is applied.

Return exactly function NAME(PARAM) { return PARAM OP INTEGER; }, with single ASCII spaces where shown and no whitespace before or after. Keep the name, parameter, operator and number as they are. Do not run the code or change the input.

The input never has other statements, calls, comments, strings, nested blocks, this, arguments, super, async or generator functions, or caller context that depends on constructors or hoisting.

Function

repairRestrictedFunction(source: String) → String

Examples

Example 1

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

The semicolon before the closing brace is missing. Add it back and write the declaration with the required spaces.

Example 2

source = "function foox){return x+9;}"return = "function foo(x) { return x + 9; }"

The opening parenthesis is missing, so the name and parameter ran together as foox. The parameter after return is x, so the name is foo and the parameter is x. Add the parenthesis between them and write the declaration with the required spaces.

Example 3

source = "function times(n) return n*3;}"return = "function times(n) { return n * 3; }"

The opening brace before return is missing. Every other token is unchanged. Add the brace back and write the declaration with the required spaces.

Constraints

  • 1 <= source.length <= 200, counted in ASCII characters after the character was removed.
  • The input comes from a declaration of the shape above with exactly one of the listed punctuation characters deleted. It has exactly one valid repair in the required output form.
  • 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.
  • The integer text is 0, or one to 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
  • Convert a Restricted Function to an Arrow FunctionPHONE 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 repairRestrictedFunction(String source) {
        // Write your code here.
        return "";
    }

}
Checking account…