Check values in the Array is a String
Given an array
Sample Input 1
[ 'frozen', 'rock', 'stained', 'basket' ]
Sample Output 1
true
Sample Input 2
[ 'recycling', 70, 'pastime', 'animal' ]
Sample Output 2
false
Square at Alternate Indices
Given an array
Sample Input 1
[ 1, 2, 3, 4, 5 ]
Sample Output 1
[ 1, 2, 9, 4, 25 ]
Sample Input 2
[ 2, 4 ]
Sample Output 2
[ 4, 4 ]
Filter Unique Characters
Given a string
myString as an input, write a JS program to find the unique characters from the myString.
Quick Tip
You can use the array method indexOf().
Sample Input 1
Was it a cat I saw?
Sample Output 1
[
'W', 'a', 's', ' ',
'i', 't', 'c', 'I',
'w', '?'
]
Sample Input 2
I did, did I?
Sample Output 2
[ 'I', ' ', 'd', 'i', ',', '?' ]
String Starts or Ends with given String
Given an array
stringsArray of strings, and startString, endString as inputs, write a JS program to filter the strings in stringsArray starting with startString or ending with endString.
Quick Tip
You can use the array method filter() and logical operator OR ( || ).
Sample Input 1
['teacher', 'friend', 'cricket', 'farmer', 'rose', 'talent', 'trainer']
t
r
Sample Output 1
[ 'teacher', 'farmer', 'talent', 'trainer' ]
Sample Input 2
['dream', 'player', 'read', 'write', 'trend']
p
d
Sample Output 2
[ 'player', 'read', 'trend' ]
String Slicing
Given two strings
Sample Input 1
JavaScript
S
Sample Output 1
Script
Sample Input 2
Language
air
Sample Output 2
Language
Split and Replace
Given three strings
inputString, separator and replaceString as inputs. Write a JS program to split the
inputString with the given separator and replace strings in the resultant array with the replaceString whose length is greater than 7.
Quick Tip
Sample Input 1
JavaScript-is-amazing
-
Programming
Sample Output 1
Programming is amazing
Sample Input 2
The&Lion&King
&
Tiger
Sample Output 2
The Lion King
Check values in the Array is a String
Given an array
Sample Input 1
[ 'frozen', 'rock', 'stained', 'basket' ]
Sample Output 1
true
Sample Input 2
[ 'recycling', 70, 'pastime', 'animal' ]
Sample Output 2
false
A new bakeshop is giving 50% off on all its products for its first 20
customers (regardless of age) for the store opening. After the 20th
customer, there will 10% discounts and all senior citizens receive an
additional 20% discount.
Write a pseudocode and create PHP program that performs the
necessary calculations, using Switch statement. Your program should
prompt the user for the total amount, calculate and display appropriate
discounts. Make the program as realistic as possible.