I am trying to console log my lines and it is not showing anything
// The global variable
var globalTitle = "Winter Is Coming";
// Only change code below this line
function urlSlug(title) {
let newTitle=globalTitle.slice(globalTitle.length)
console.log(newTitle)
let lowCaseTit=title.toLowerCase()
for(let i=0;i<lowCaseTit.length;i++){
if(lowCaseTit[i]=" "){
llowCaseTit.splice(i,1,"-")
console.log(lowCaseTitle);
}
}
}
// Only change code above this line
// The global variable
var globalTitle = "Winter Is Coming";
// Only change code below this line
function urlSlug(globalTitle) {
let newTitle=globalTitle.slice(globalTitle.length)
console.log(newTitle)
let lowCaseTit=title.toLowerCase()
for(let i=0;i<lowCaseTitle.length;i++){
if(lowCaseTitle[i]=" "){
lowCaseTitle.splice(i,1,"-")
// console.log(lowCaseTitle);
}
return
}
}
// Only change code above this line
I mean that you need to try to run your function, not declare it with a different variable name.
// The global variable
var globalTitle = "Winter Is Coming";
// Only change code below this line
function urlSlug(title) {
let newTitle=globalTitle.slice(globalTitle.length)
console.log(newTitle)
let lowCaseTit=title.toLowerCase()
for(let i=0;i<lowCaseTit.length;i++){
if(lowCaseTit[i]=" "){
llowCaseTit.splice(i,1,"-")
console.log(lowCaseTitle);
}
}
}
urlSlug(globalTitle);
// Only change code above this line
How may I update the value of newTitle?
1st Cycle= lowerCaseTitle[6].concat(hyphen). I get “winter-is coming”. Now, I want to use that result. How may I do it?
var globalTitle = "Winter Is Coming";
// Only change code below this line
function urlSlug(title) {
let lowerCaseTitle =title.toLowerCase()
let hyphen=("-");
//console.log(indexWhiteSpace)
for (let i=0;i<lowerCaseTitle.length;i++){
//console.log(hyphen)
if(lowerCaseTitle.indexOf(" ")>=0){
let newTitle =lowerCaseTitle[lowerCaseTitle.indexOf(" ")].concat(hyphen)
//console.log(newTitle)
}
}
}
console.log(urlSlug(globalTitle));
// Only change code above this line
// The global variable
var globalTitle = "Winter Is Coming";
// Only change code below this line
function urlSlug(title) {
let newTitle= title.trim().split(/\s+/).join('-').toLowerCase();
return newTitle
}
console.log(urlSlug(globalTitle));
// Only change code above this line
//title.split(/\s+/).join('-').toLowerCase().