var totalPhoneBill = function(string){
var data = string.split(’, '); //console.log(data);
var sms =
var call =
var smsCost = 0.65
var callCost = 2.75
for(var i = 0;i<data.length;i++){
if(data[i]==‘sms’){
sms.push(data[i]);
}
if(data[i]==‘call’){
call.push(data[i])
}
} //console.log(sms.length);
var totalCost = smsCost.length * callCost.length;
console.log(totalCost);
return totalCost
}
totalPhoneBill(‘call, sms, call, sms, sms’)
<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>
<Below this line, add a link to the EXACT exercise that you are stuck at.>
<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
I thanks guys that was very helpful.but i actually got to the answer lol…
I tried several steps and suddenly i got to itvar totalCost = smsCost*‘3’ + callCost*‘2’;
yip thanks that worked…i have another complication if u don’t mind…need to find the longestWord and the wordsLength.Given a sentence write some functions (function names in brackets) that can:
Find the longest word (longestWord);
find the shortest word (shortestWord);
find the sum of all the word lengths, in a sentence. (wordLengths).
Use split to split the string.
You need a for loop to loop threw the created array.
In the loop put a if statement that compares the longest word length (stored in the first round from your loop)) with the actual word in the array
var longestWord = function(string){
var data = string.split(’,’)
var longestWord = [collaboration]
for(var i = 0;i < data.length;i++){
if(data[i] = longestWord.length){
longestWord.push(data[i])
hi! its me again lol…need to subtract this (callCost * call.length) + (dataCost * data.length) + (smsCost * sms.length)
from 50… if anyone could please help…sorry for being so disturbing…how should i structure that