Question

use swift language Write a function that will accept an array of Emoji symbols of size...

use swift language

Write a function that will accept an array of Emoji symbols of size N and randomly returns a sumbol from the array. This function will have one parameter, the Array of Emoji Symbols and will return One emoji symbol as a String.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

func REArray(Size: Int, arrayE: [String]) -> String
{
for value in arrayE[1..<array.count]
{
   let randomEmoji = arrayE.randomElement()
return randomEmoji
}
}

Here size is the size of the array and arrayE is the array of emoji symbols. REarray is a function which accept the array arrayE and size as a parameter and return random element from the array as per the requirement of the question.

Add a comment
Know the answer?
Add Answer to:
use swift language Write a function that will accept an array of Emoji symbols of size...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using swift 4.0, Write a function (not method) named findName which returns a given name (passed...

    Using swift 4.0, Write a function (not method) named findName which returns a given name (passed as a parameter) if it is in the string array passed as a parameter, otherwise return nil Demonstrate calling the function findName. Using swift 4.0

  • Write in C language 5. [8] Write a function with prototype » void string_copy(const char source[],...

    Write in C language 5. [8] Write a function with prototype » void string_copy(const char source[], char destination[], int n); This function copies string source to string destination. Parameter n represents the size of array destination. If the latter array is not sufficiently large to hold the whole source string then only the prefix of the string which has room in the latter array should be copied. Note that after copying, the null character should also be included to mark...

  • Using Swift, Write a program that reads in a string and passes to a function named...

    Using Swift, Write a program that reads in a string and passes to a function named parse(digit:) that takes a string with one character as parameter. The function should return -1 if the input is not a digit character and the digit otherwise. You must use a switch statement parse(digit: "1") // 1 parse(digit: "3") // 3 parse(digit: "a") // -1

  • Using Swift playground and / or the command line for macOS (open Xcode, create a new...

    Using Swift playground and / or the command line for macOS (open Xcode, create a new Xcode project, macOS, command line tool), practice the following exercises: Exercise: Swift Variables Declare 2 variables/constants with some random values and any name of your choice Considering these 2 variables, one as a value of PI and other as a radius of circle, find the area of circle Print the area of circle Declare a string variable explicitly with value “Northeastern”. Declare a string...

  • please use c ++ language and write the comment too. thanks Pointer Arithmetic Write a function...

    please use c ++ language and write the comment too. thanks Pointer Arithmetic Write a function that passes an array address to a function as a pointer. Using pointer arithmetic, the function determines the average, high, and low value of the array. Your function should have this header: void pointerArithmetic(int *array, int size, double &average, int &high, int &low) Parameter size is the number of elements in array. You may not use the subscript notation [] inside your function –...

  • In matlab, there is a function "size" that accepts an array as a parameter (or input...

    In matlab, there is a function "size" that accepts an array as a parameter (or input argument) and returns the dimensions of that array as another single-dimension array.      For example, if the array were 2 x 2, it would return [2 2]. Assume that input1 is a 1 or 2-dimensional array. Use the size function to obtain the dimensions and save the output into the return argument of this function "output1"     1Do not modify the line below 2-unction...

  • Write a value-returning C++ function returns the average length of an array of strings. Name the...

    Write a value-returning C++ function returns the average length of an array of strings. Name the function stringsAverageLength and use the following header: double stringsAverageLength(string array [], int n) { } where the parameter 'array' has 'n' strings and the return value is the average length of all of the strings in the array. For example, if the function is called like this: string cars[3] = { "Toyota", "Ford", "Tesla" }; cout << fixed << setprecision(2) << stringsAverageLength(cars, 3) <<...

  • #Swift programming language • For each: Implement a function forEach(array: [Int], _ closure: Int -> ())...

    #Swift programming language • For each: Implement a function forEach(array: [Int], _ closure: Int -> ()) that takes an array of integers and a closure and runs the closure for each element of the array. Example: var array = [1,2,3,4] forEach(array) { print($0 + 1) }

  • c++ program8. Array/File Functions Write a function named arrayToFile. The function should accept three arguments:...

    c++ program8. Array/File Functions Write a function named arrayToFile. The function should accept three arguments: the name of a file, a pointer to an int array, and the size of the array. The function should open the specified file in binary mode, write the contents of the array to the file, and then close the file. Write another function named fileToArray. This function should accept three argu- ments: the name of a file, a pointer to an int array, and the size...

  • Write a function that will accept an array of string. Return the index of the element...

    Write a function that will accept an array of string. Return the index of the element that has the most vowels. For this exercise, vowels are a,e,i,o, and u. If none of the strings contain a vowel, return -1. If two or more words contain the same largest amount of vowels, either index of such words is acceptable. (using C++)

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT