Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Show/Hide Element in jQuery
00:00
5 left

Show/Hide Element in jQuery

EasyPython

Problem

The Saint-Gobain Glassolutions product configurator displays or hides interface panels based on the user's selections. Write a function that generates the exact jQuery command needed to show or hide an HTML element.

Given a CSS selector and a Boolean visibility value, return $(selector).show(); when the element should be visible, or $(selector).hide(); when it should be hidden. The selector must be inserted between $( and ) and preserved exactly.

Formal Specification

Implement jquery_visibility_command(selector, visible).

  • selector is a non-empty string containing a valid CSS selector.
  • visible is a Boolean.
  • Return a string containing the corresponding jQuery command.

Constraints

  • 1 <= len(selector) <= 100
  • selector contains no newline characters
  • visible is always a Boolean
  • Return only the generated command string

Function Signature

def jquery_visibility_command(selector, visible):
Interviewer

Your question is Show/Hide Element in jQuery. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
Sign up free to run your codeLog inLn 2
Run your code to see test output here.