Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Javascript - Have the function StringScramble(str1,str2) take both parameters being passed and return the string true if a portion of str1 characters can be rearranged

Javascript - Have the function StringScramble(str1,str2) take both parameters being passed and return the string true if a portion of str1 characters can be rearranged to match str2, otherwise return the string false. For example: if str1 is "rkqodlw" and str2 is "world" the output should return true. Punctuation and symbols will not be entered with the parameters. Examples Input: "cdore" & str2= "coder" Output: true Input: "h3llko" & str2 = "hello" Output: false

Before responding with your answer - pls include the code below that is required in my answer. The format is below. Thank you.

function StringScramble(str1,str2) {

// code goes here

let [arr1,arr2] = [str1.split(''), str2.split('')];

return arr2.every(x=>arr1.indexOf(x) ===1? false: arr1.splice(arr1.indexOf(x), 1));

return str1;

}

// keep this function call here

console.log(StringScramble(readline()));

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

13th Edition Global Edition

1292263350, 978-1292263359

More Books

Students also viewed these Databases questions

Question

=+designing international assignment C&B packages.

Answered: 1 week ago

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago