id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

abraskin@mbusd.org > add
prev  |  next  |  chance

Given an array of Strings, a String element, and an index, return an array with the element inserted in the array at the index.


If the index is out of bounds, return the array unchanged.

add(["0", "1", "2", "3", "4"], "-1", 2) → ["0", "1", "-1", "2", "3", "4"]
add(["A", "B", "C", "D"], "*", -1) → ["A", "B", "C", "D"]
add(["A", "B", "C", "D"], "*", 0) → ["*", "A", "B", "C", "D"]

...Save, Compile, Run (ctrl-enter)

public String[] add(String[] arr, String e, int index) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 200

Copyright Nick Parlante 2017 - privacy