5 kyu

Argument Mapper

Description:

As part of a broader functionality you need to develop an argument mapper.

The function receives a function object as first parameter and an unknown number of arguments [zero to many]. You have to return an associative array that maps the name of an argument and its related value.

The usage is:

function func1(arg1, arg2) { ... }

var map = createArgumentMap(func1,'valueOfArg1', 'valueOfArg2');
console.log(map['arg1']);  // writes 'valueOfArg1'
console.log(map['arg2']);  // writes 'valueOfArg2'

The passed values are in the same order as they appear in the function object.

Invalid inputs, e.g. non-function objects, or wrong number of arguments, are not considered.

Hajime!

Reflection
Fundamentals

Stats:

CreatedFeb 15, 2014
PublishedFeb 15, 2014
Warriors Trained1516
Total Skips397
Total Code Submissions3360
Total Times Completed601
JavaScript Completions601
Total Stars24
% of votes with a positive feedback rating83% of 101
Total "Very Satisfied" Votes73
Total "Somewhat Satisfied" Votes21
Total "Not Satisfied" Votes7
Ad
Contributors
  • ohager Avatar
  • jhoffner Avatar
Ad