0% found this document useful (0 votes)
95 views

Create A Function That Takes A String and Returns It As An Integer

The document provides examples for 4 functions: 1) A function that takes a string and returns it as an integer. 2) A function that takes a string and replaces "amazing" with "not amazing", except if "edabit" is in the string. 3) A function that adds a character between each word in a string. 4) A function that returns true if k to the power of k equals the first argument n, and false otherwise.

Uploaded by

Ines Daboussi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
95 views

Create A Function That Takes A String and Returns It As An Integer

The document provides examples for 4 functions: 1) A function that takes a string and returns it as an integer. 2) A function that takes a string and replaces "amazing" with "not amazing", except if "edabit" is in the string. 3) A function that adds a character between each word in a string. 4) A function that returns true if k to the power of k equals the first argument n, and false otherwise.

Uploaded by

Ines Daboussi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

1- Create a function that takes a string and returns it as an integer.

Examples
stringInt("6") ➞ 6
stringInt("1000") ➞ 1000
stringInt("12") ➞ 12

2- Create a function that takes a string and changes the word amazing to not amazing. Return the
string without any change if the word edabit is part of the string.

Examples

amazingEdabit("edabit is amazing.") ➞ "edabit is amazing."


amazingEdabit("Mubashir is amazing.") ➞ "Mubashir is not amazing."
amazingEdabit("Infinity is amazing.") ➞ "Infinity is not amazing."

3- WordCharWord
Create a function that will put the first argument, a character, between every word in the second
argument, a string.

Examples

add("❤", "I love Tesh!") ➞ "I❤love❤Tesh!"


add("👍", "Java is a lot of fun.") ➞ "Java👍is👍a👍lot👍of👍fun."
add("#", "hello world!") ➞ "hello#world!"
add("&", "you me world") ➞ "you&me&world"

4- Testing K^K == N?
Write a function that returns  true  if  k^k == n  for input  (n, k)  and return  false  otherwise.

Examples

kToK(4, 2) ➞ true
kToK(387420489, 9) ➞ true
// 9^9 == 387420489
kToK(3124, 5) ➞ false
kToK(17, 3) ➞ false

5-
6-

You might also like