iOS Swift Basics An Introduction to Swift Programming Working With Variables

Em Har
Em Har
9,775 Points

Variable named language

im putting var str = "swift" but my error says make sure your variable is a named language. What do I do?

variables.swift
// Enter your code below

var str = "swift"

2 Answers

KRIS NIKOLAISEN
KRIS NIKOLAISEN
54,331 Points

make sure your variable is named language

var language = "Swift"
Caleb Kleveter
MOD
Caleb Kleveter
Treehouse Moderator 37,861 Points

Your variable looks like this:

var str = "swift"

A variable has 4 components:

  • The variable keyword (var)
  • The name of the variable (in your case str)
  • The assignment operator (=)
  • The variable's value (in your case "swift")

The error you are getting says you need to make sure you have a variable named language, so you should change the second component I listed to fix that. Though your code technically works, the challenge expects a specific name for the variable.

As a side note, make sure the casing of the string you assign the variable to is correct. Swift might be correct while swift could cause the challenge to fail.

Em Har
Em Har
9,775 Points

I appreciate it!